因此,我在另一個(gè)ng-repeat中嵌套了一個(gè)ng-repeat,以構(gòu)建導(dǎo)航菜單。在<li>內(nèi)部ng-repeat循環(huán)的每個(gè)循環(huán)上,我都設(shè)置了一個(gè)ng-click,它通過(guò)傳入$ index來(lái)調(diào)用該菜單項(xiàng)的相關(guān)控制器,以使應(yīng)用知道我們需要哪個(gè)。但是,我還需要從外部ng-repeat傳遞$ index,以便應(yīng)用程序知道我們?cè)谀膫€(gè)部分以及哪個(gè)教程中。<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>這是一個(gè)傻瓜http://plnkr.co/edit/bJUhI9oGEQIql9tahIJN?p=preview
在嵌套的ng-repeat中傳遞2個(gè)$ index值
小怪獸愛(ài)吃肉
2019-11-06 10:44:56