I'm new to angular JS and I try to use ng-repeat to generate multiple lines in my table I am doing this, and each row contains one parameter
{{Item.prop1}} & lt; / Td> & Lt; Td> {{Item.prop2}} & lt; / Td> & Lt; Td> & Lt; Button ng-click = "my function (item.id)" & gt; Trigger function & lt; / Button & gt; & Lt; / Td> & Lt; / TR & gt; & Lt; / Tody & gt; & Lt; / Table & gt; & Lt; / Div & gt;
This definitely does not work, because ng-repeats create its own realm, whereas myFunction is defined in the parent area (i.e. test controller) .
However, what I find in Google's results is the reason not to work, but there is no way to fix the problem. How do I fix my code to work ng-click? What is the way to define my function within the ng-repeat scope or is there a way to say that I want the function in the field of parental status?
Please read the comments below the question. The comment is actually doing better by testing my code and the code works. It helps me to realize this problem, which shows that the function I am calling is accidentally placed under the control of a child in the actual controller.
The answer is good but does not solve the problem. It is worth reading something, but I do not like to mark them as the correct answer so that people do not mislead.
No comments:
Post a Comment