0

I have this code and not sure is it right or wrong the way to implement it. But definitely so far not working in my view.

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

Well, I tried to make value of indexX=0 at ng-init="indexX=0". Is it true the way I've done it?

The purpose I need to reset the value of indexX is because of nested loop of ng-repeat at the outer div.

Nere
  • 4,097
  • 5
  • 31
  • 71

1 Answers1

0

You can add a directive to your ng-repeat loop that can utilize the scope.$last parameter to reset your index on the last element.

Example: https://stackoverflow.com/a/13472605/6452040

Community
  • 1
  • 1
estacks
  • 104
  • 4