using ng-repeat inside another ng-repeat

女生的网名这么多〃 提交于 2019-11-30 05:00:44

ng-repeat's create their own $scope.

So, for the inner ng-repeats, you have access to $parent.$index, where $parent is the parent scope of the current repeat block.

For ex:

<ul ng-repeat="section in sections">
  <li>
      {{section.name}}
  </li>
  <ul>
    <li ng-click="loadFromMenu($parent.$index)" ng-repeat="tutorial in section.tutorials">
          {{tutorial.name}}
    </li>
  </ul>
</ul>

Plunkr http://plnkr.co/edit/hOfAldNevxKzZQlxFfBn?p=preview

(simplified from this answer passing 2 $index values within nested ng-repeat)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!