1

In my angularJS I'm using ng-repeat to iterate through comments like so.

<li class="item block-size" ng-repeat="comment in comments" >
                    <div class="header">
                        <span class="count">{{$index + 1}}</span>
                        <span class="people">3 <i class="icon-user icon-large"></i></span>
                        <span class="comments">5 <i class="icon-comments-alt icon-large"></i></span>
                        <span class="open"><a href="#conversation-modal" role="button"  ng-click="commentPopup({{comment.comment_id}})" ><i class="icon-external-link icon-large"></i>Onions</a></span>
                    </div>
<li>

In ng-click, I am calling a function the controller called commentPopup, which is suppose to take the currents comment id. The problem is it does not work with expressions. The function looks like this:

$scope.commentPopup = function(comment_id) {

         alert(comment_id);

    };

If I do

commentPopup(1);

it works. But if I do

commentPopup({{comment.comment_id}})

I does not work. Can anyone else me how to pass the comment id into this function?

1
  • 2
    commentPopup(comment.comment_id) Commented Jul 1, 2013 at 14:41

1 Answer 1

12

If you want to pass along this data, try removing the {{}} so the call will just look like

ng-click="commentPopup(comment.comment_id)"

This should automatically fill in the comment id once it has compiled the template of the ng-repeat

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.