如何在嵌套ng-repeats中访问超级父级的索引 [英] How to access the index of super parent in nested ng-repeats

查看:60
本文介绍了如何在嵌套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.

Angular文档专门有此示例

这篇关于如何在嵌套ng-repeats中访问超级父级的索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆