【发布时间】:2015-04-07 23:16:03
【问题描述】:
我在对象上使用嵌套的 ng-repeat 和过滤器。第一个 ng-repeat 是对 gapHeader 对象中的 headerId 的过滤器。第二个 ng-repeat 过滤 gapSection、sectionId 到对应的 headerID。
我有一个编辑页面,它位于一个单独的模式窗口中。目的是编辑子对象的headerID和sectionID对应的内容)这个也有单独的控件。数据通过服务共享。
我的问题我的每个 gapSection 子对象都有一个按钮,它打开编辑页面模式,当我将每个部分中当前部分的 $index 值传递给服务时,我得到的 $index 只对应于第二次重复?例如,如果我在 gapSection (headerId:2, sectionId:2) 上单击 2 ng-repeat 中的按钮,我会得到一个 $index 1。我需要一个 $index 2,它对应于 gapSection 中的子对象位置.
是否可以传递真正的 $index,它对应于 gapSection 的原始未过滤对象中定义的 $index?感谢任何关于此的 cmets,谢谢!
对象:
var data ={
gapHeader:[{headerId:1,name:"General Requiremets",isApplicable:true},
{headerId:2,name:"Insurance",isApplicable:false}],
gapSection:[{headerId:1,sectionId:1,requirement:"A facility is required to have company structure",finding:null,cmeasures:null,cprocedures:null,personResp:null,isAction:null},
{headerId:2,sectionId:1,requirement:"Organisation must have public liablity",finding:null,cmeasures:null,cprocedures:null,personResp:null,isAction:null},
{headerId:2,sectionId:2,requirement:"Facility must hold workers compensation insurance",finding:null,cmeasures:null,cprocedures:null,personResp:null,isAction:null}]
};
【问题讨论】:
-
这看起来类似于以下内容:[nested ng-repeat and $index issue][1] [1]: stackoverflow.com/questions/15256600/…
标签: angularjs