Horrible Guy Horrible Guy - 5 months ago 8
Javascript Question

storing data related to 'ng-repeat'ed items

I have a site showing a list of comments and the comments can be liked by clicking a button.

The site is written using angular and the list of comments are fetched from a node back end and rendered using

of Angular.
To record a like I need to pass some information related to the comment to the node endpoint via AJAX.

The problem is that I don't wanna store any information related to the comment on the DOM. And I did not get how I can use jQuery.data here since I am '
'ing to render the comments.

Please suggest some alternatives..

Here is how the comments are rendered

<div class="stickyNotes" ng-repeat="comment in commentList1">
<a href=""><img src="../resources/images/thumb.png" class="upvoteImage" /> </a>


You can use $index, and pass it to your controller method onClick. Then you can access the exact comment $scope.commentList1[index] on your controller, and do what you what with it.

you can learn about $index here: