Passing multiple argument to ng-click method

前端 未结 1 1871
温柔的废话
温柔的废话 2021-01-03 19:45

In my code i like to pass to arguments to the function specified inside the ng-click attribute.

<
相关标签:
1条回答
  • 2021-01-03 20:08

    You don't need {{ }} while specifying arguments to an event handlers (ng-click). The correct syntax would be ng-click="deleteUser($index, user._id):

    <div class="shout" ng-repeat="user in users">
     <p>{{user.name}}</p>
     <img src="media/images/delete.png" ng-click="deleteUser($index, user._id)"/>
    </div>
    

    Here is a working plunker based on the code you've provided (check the console to see that click handler is working correctly): http://plnkr.co/edit/26A4Rj0FScPXYU7z92E6?p=preview

    0 讨论(0)
提交回复
热议问题