0

I have several buttons,which's id is given by data that I ajax,and every id is different.

<a href="#" class="btn btn-primary likes" id="{{data.id}}" role="button" ng-click="likes()">XXX</a>

How do I detect a button's id when it is clicked?

  • I suggest you to read this post: http://stackoverflow.com/questions/14994391/how-do-i-think-in-angularjs-if-i-have-a-jquery-background – Dieterg Jan 22 '14 at 10:36

2 Answers2

1

Pass the id to the likes function:

ng-click='likes(data.id)'
Gruff Bunny
  • 27,738
  • 10
  • 72
  • 59
1

you can use like this

data-ng-click='likes(data.id)'

or if you want pass the index of element

data-ng-click='likes($index)'
Ravi
  • 853
  • 8
  • 17