Service Portal Dynamically Add ng-click

xiaix
Tera Guru

find_real_file.png

find_real_file.png

The span appears just fine, but when I click it, nothing happens.   If I do a regular onclick="", then of coure is screams "iGotClicked is not defined".

I know I need to use ng-click, but I'm not allowed to dynamically add it?

2 REPLIES 2

Jon Barnes
Kilo Sage

You won't be able to do it that way because the angular bind functionality will have already happened and won't trigger again after you add that HTML snippet. Since for the most part angular is meant to be declarative, I would recommend put your span in there in your template with an ng-if if you don't want to show it in certain cases. Or put the ng-click in all cases, but decide inside the ng-click function based on certain criteria whether you are going to run the functionality.



If you explain your use case, I may be able to suggest something more specific though.


Your explanation of binding makes complete sense.   That was the answer I was looking for.   Thank you.



I'm dynamically building a calendar.   For each day that's put in, I'm want to allow the user to click the day and be able to edit.



All the code (html) is dynamically "stuffed" into the calDiv div in script.