所以我有一个ng-repeat嵌套在另一个ng-repeat中,以便构建一个导航菜单.在<li>内部ng-repeat循环中的每一个上,我设置了一个ng-click,它通过传入$ index来调用该菜单项的相关控制器,让应用程序知道我们需要哪一个.但是我还需要从外部ng-repeat传入$ index,以便app知道我们所在的部分以及哪个教程.
<ul ng-repeat="section in sections">
<li class="section_title {{section.active}}" >
{{section.name}}
</li>
<ul>
<li class="tutorial_title {{tutorial.active}}" ng-click="loadFromMenu($index)" ng-repeat="tutorial in section.tutorials">
{{tutorial.name}}
</li>
</ul>
</ul>
Run Code Online (Sandbox Code Playgroud)
这是一个Plunker http://plnkr.co/edit/bJUhI9oGEQIql9tahIJN?p=preview