Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJs ng-click event only triggered with literal arguments

When I call within a ng-repeat group

<span ng-click="remove({{user.id}})">Delete</span>

the remove function is not called

but when I replace the expression by a literal argument it gets called (works properly):

<span ng-click="remove(123)">Delete</span>

The '{{user.id}}' expression is evaluated properly and has only integer values.

Anybody an idea what is going on? Same happens with anchor tags (with href="").

like image 675
Sam Avatar asked Oct 13 '12 19:10

Sam


2 Answers

ng-click="remove(user.id)" should work, ng-click evaluate it content so you don't need interpolation

like image 108
Renan Tomal Fernandes Avatar answered Oct 25 '22 17:10

Renan Tomal Fernandes


You shouldn't use curly braces in the ng-click expressions. Try this instead:

<span ng-click="remove(user.id)">Delete</span>

And be sure to check the AngularJS expressions documentation: http://docs.angularjs.org/guide/expression

like image 32
pkozlowski.opensource Avatar answered Oct 25 '22 18:10

pkozlowski.opensource