2

Suppose my html looks like

 <h2>Unapproved Users<span class="badge">12</span></h2>
<ul class="list-group" ng-repeat="user in unApprovedUsers">
    <li class="list-group-item">{{user.Name}} <button class="btn btn-success" ng-click="ApproveUser({{user.ID}})">Approve</button></li>

</ul>

the problem is that approve user cannot be called while sending that argument so how can i send it to the function

JenuRudan
  • 545
  • 1
  • 14
  • 30
  • Duplication of this one: http://stackoverflow.com/questions/17039926/adding-parameter-to-ng-click-function-inside-ng-repeat-doesnt-seem-to-work – Dmitri Pavlutin Dec 25 '15 at 13:53

2 Answers2

4

You do not need the {{ }}. You may directly access the user object and it's properties.

ng-click="ApproveUser(user.ID)"

The double curly braces binding expression({{ }}) tells Angular that it should evaluate the expression inside the double curly braces and insert the result into the DOM in place of the original binding expression .

Since you want to access the user object and pass the property value to your function, you do not need {{ }}. You can simply access the object and use the property value and pass it to your method.

Shyju
  • 214,206
  • 104
  • 411
  • 497
4

Remove brackets {{ }},

ng-click="ApproveUser(user.ID)"
Oleksandr T.
  • 76,493
  • 17
  • 173
  • 144