本文介绍了如何在嵌套ng-repeats中访问超级父级的索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想访问最外面的ng-repeat的索引.
I want to access the index of the outermost ng-repeat.
<div ng-repeat="">
<div ng-repeat="">
<div ng-repeat="">
//I want to get the $index of outer ng-repeat here
</div>
</div>
</div>
推荐答案
使用ng-init
设置外部索引:
<div ng-repeat="" ng-init="outerIndex = $index">
然后您可以在其他作用域中使用outerIndex
.
Then you can use outerIndex
in the other scopes.
这篇关于如何在嵌套ng-repeats中访问超级父级的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!