我有一个编辑页面,它位于一个单独的模态窗口中.目的是编辑对应于headerID&的内容.子对象的sectionID)这也有一个单独的控件.数据通过服务共享.
我的问题我有一个按钮用于每个gapSection子对象,它打开编辑页面模态,当我将每个部分中当前部分的$index值传递给服务时,我得到的$index仅对应于第二个ng-重复?例如,如果我单击gapSection上的2 ng-repeat内的按钮(headerId:2,sectionId:2),我得到$1的索引.我需要$index为2,它对应于gapSection中的子对象位置.
是否有可能传递真正的$index,它对应于gapSection的原始未过滤对象中定义的$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},requirement:"Organisation must have public liablity",sectionId:2,requirement:"Facility must hold workers compensation insurance",isAction:null}] };
即
$scope.gapSectionFn = function(obj){ var idx = data.gapSection.indexOf(obj); }
另外还不清楚你的问题是否真的可能是嵌套的ng-repeat问题,因为根据你的说法,gapSection是内部ng-repeat,你正在调用内部ng-repeat和需要gapSection索引的调用.它应该是可用的,但是DOM过滤器的存在只会重新生成项目及其索引,您也可以通过执行ng-init
来获取它,即在视图ng-init =“actIndex = $index”上并使用actIndex.
如果您尝试访问父ng-repeat的索引,那么ng-init比$parent更合适.$index.由于ng-init是专门为此设计的,因此在父ng-repeat上你会写ng-init =“”parentIndex = $index“并使用parentIndex.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。