AngularJS - 在过滤的ng-repeat中的对象的原始索引
AngularJS - 在过滤的ng-repeat中的对象的原始索引
我正在使用嵌套的ng-repeat和一个对象上的过滤器。第一个ng-repeat根据gapHeader对象中的headerId进行过滤。第二个ng-repeat将gapSection和sectionId过滤到相应的headerID中。\n我有一个编辑页面,它位于一个单独的模态窗口中。目的是编辑与子对象的headerID和sectionID相对应的内容。这也有一个单独的控制器。数据通过服务共享。\n我的问题是,我为每个gapSection子对象都有一个按钮,当我将当前section中的$index值传递给服务时,我只得到了对应于第二个ng-repeat的$index?例如,如果我在gapSection的第2个ng-repeat上点击按钮(headerId:2,sectionId:2),我得到的$index是1。我需要一个$index是2,对应于gapSection中子对象的位置。\n是否可能传递对应于gapSection原始未过滤对象中定义的$index的真正$index?对此的任何评论将不胜感激,谢谢!\n对象:\n
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}] };