简体   繁体   English

ng-repeat内的ng-repeat在angularjs应用中不起作用

[英]ng-repeat inside ng-repeat not working in angularjs app

I am using two ng repeats but the second one it doesnt display. 我正在使用两个ng重复,但第二个不显示。 Let me show you my view : 让我告诉你我的看法:

<div  class="post" ng-repeat="user in users | orderBy:'username':false" ng-class-odd="'odd'" ng-class-even="'even'">
  <p>{{user.username}}</p> 
  <small><a ng-click='gotomessages(user.username)' class="btn btn-default">go</a></small>     
  <small class="pull-right"> Message</small>
  <div ng-repeat="message in messages[$index]">
    <p>{{message.name}}</p>   
  </div>
</div>

the $index is the one of the first ng-repeat. $ index是第一个ng-repeat之一。 Is it possible to use it like i did ? 有可能像我一样使用它吗? In anyway the second ng repeat doesnt work can you help 无论如何,第二次重复是行不通的,你能帮忙吗

只需在第二个ng-repeat使用$parent.messages[$index]而不是messages[$index]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM