每个ng-repeat都会使用传递的数据创建一个子作用域,并
$index在该作用域中添加一个附加变量。
因此,您需要做的是达到父级作用域并使用
$index。
看到http://plnkr.co/edit/FvVhirpoOF8TYnIVygE6?p=preview
<li ng-click="loadFromMenu($parent.$index)" ng-repeat="tutorial in section.tutorials"> {{tutorial.name}}</li>
每个ng-repeat都会使用传递的数据创建一个子作用域,并
$index在该作用域中添加一个附加变量。
因此,您需要做的是达到父级作用域并使用
$index。
看到http://plnkr.co/edit/FvVhirpoOF8TYnIVygE6?p=preview
<li ng-click="loadFromMenu($parent.$index)" ng-repeat="tutorial in section.tutorials"> {{tutorial.name}}</li>