[英]How to reset the value of $index in ng-repeat nested loops?
我有这段代码,但不确定实现它的方式是对还是错。 但到目前为止,在我看来,绝对没有用。
<div ng-repeat="data in DataObject">
<ul style="list-style-type:decimal !important;">
<li ng-repeat="(indexX,answer) in bkm.content_detail.question_data.question_content[0].question_answer[0].answer_text track by $index">
{{indexX+1}} - {{answer | joinBy : " / "}}
</li>
<div ng-init="indexX=0"></div>
</ul>
</div>
好吧,我试图让价值indexX=0
在ng-init="indexX=0"
我做的方式真的吗?
我需要重设indexX
是因为外部div的ng-repeat嵌套循环。
您可以在ng-repeat循环中添加一个指令,该指令可以利用scope。$ last参数来重置最后一个元素的索引。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.