AngularJS-已筛选ng repeat中对象的原始索引

AngularJS-已筛选ng repeat中对象的原始索引,angularjs,Angularjs,我在对象上使用嵌套的ng repeat和过滤器。第一个ng重复是过滤到gapHeader对象中的headerId。第二个ng重复将间隙部分、sectionId过滤到相应的headerID 我有一个编辑页面,它位于一个单独的模式窗口中。其目的是编辑与子对象的headerID和sectionID相对应的内容)这也有一个单独的控件。数据通过服务共享 我的问题是,每个gapSection子对象都有一个按钮,它打开编辑页面模式,当我将每个部分中当前部分的$index值传递给服务时,我得到的$index仅对

我在对象上使用嵌套的ng repeat和过滤器。第一个ng重复是过滤到gapHeader对象中的headerId。第二个ng重复将间隙部分、sectionId过滤到相应的headerID

我有一个编辑页面,它位于一个单独的模式窗口中。其目的是编辑与子对象的headerID和sectionID相对应的内容)这也有一个单独的控件。数据通过服务共享

我的问题是,每个gapSection子对象都有一个按钮,它打开编辑页面模式,当我将每个部分中当前部分的$index值传递给服务时,我得到的$index仅对应于第二个ng repeat?例如,如果我单击2ng repeat on gapssection(headerId:2,sectionId:2)中的按钮,我会得到$index 1。我需要一个$index 2,它对应于GapsSection中的子对象位置

是否可以传递与gapSection的原始未筛选对象中定义的$index相对应的真$index?感谢您对此的评论,谢谢

对象:

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}]



};

如果需要真正的索引,甚至不需要传递
$index
属性,只需传递对象并从原始列表中获取索引即可

i、 e

此外,还不清楚您的问题是否真的是嵌套的ng repeat问题,因为根据您的说法,gapSection是内部ng repeat,您正在调用来自内部ng repeat的调用,并且需要
gapSection的
索引。它应该是可用的,但是DOM过滤器的存在只会重新标记项目及其索引,您也可以通过执行,即在视图
ng init=“actIndex=$index”
上使用
actIndex
来获得这些项目及其索引


如果您试图访问父级ng repeat的索引,则ng init比$parent.$index更合适。由于ng init是专门为此而设计的,您可以在父ng repeat上编写
ng init=”“parentIndex=$index”
并使用parentIndex。

这看起来类似于以下内容:[嵌套的ng repeat和$index问题][1][1]:indexOf(obj)非常有效,谢谢!关于ng repeat,您是对的,第一个ng repeat确实可以在不同的对象上工作,因此我最初尝试的$parent.$index不起作用,因为我得到的是gapHeader的索引,而不是GapSection。再次感谢,我认为这比想象的要困难得多!
$scope.gapSectionFn = function(obj){
    var idx = data.gapSection.indexOf(obj);
}