我正在做的是我有帖子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也很好吗?谢谢你的帮助。
答案 0 :(得分:1)
是你要找的filter吗?
<div id="the_comments" ng-repeat="comment in comments | filter:{id:post.id}">