[英]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.