2014-02-11 115 views
0

我在做什么是我有职位ngRepeat,我有另一个意见。我不能得到这些帖子的评论,除非我有一些如何将帖子的ID传递到ngRepeat注​​释中。如何将一个ID从一个ngRepeat传递给另一个?

<div ng-app="posts" ng-controller="PostCtrl"> 
    <div id="posts_container" ng-repeat="post in posts"> 

    <div id="the_post"> 


     <!-- I've got to pass the post.id to get the right comments for that post --> 
     <div id="the_comments" ng-repeat="comment in comments"> 

     </div> 
    </div> 
    </div> 
</div> 

这在PHP foreach循环中很简单,但我没有在angularjs中弄清楚它。嵌套ng-repeat也很好吗?谢谢你的帮助。

回答

1

是否filter你在找什么?

<div id="the_comments" ng-repeat="comment in comments | filter:{id:post.id}"> 
+0

哇这么简单,它的作品就像一个魅力谢谢你的回答。 – dragonfire1119

相关问题