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?

4

1 回答 1

12

如果您想传递此数据,请尝试删除,{{}}以便调用看起来像

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

一旦编译了ng-repeat

于 2013-07-01T14:41:48.113 回答