Deepak Kumar Deepak Kumar - 4 months ago 8
AngularJS Question

How to find loop number in ng-repeat in AngularJS


I have to get the question number in this loop.


<div ng-repeat="quizqs in Quizdata.questions">
<li ng-click="form.goTo(Form, 1)">
<a href ng-class="{'selected' : currentStep >= 1, 'done' : currentStep > 1}">
<div class="stepNumber">
1
</div> <span class="stepDesc text-small">Question No {{quizqs.id}} - {{Quizdata_Lenght}}</span>
</a>
</li>
</div>

Answer

You can use {{$index}}

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script>
<div ng-app>
  <div ng-repeat="quizqs in [12,43,354,13,653]">
    <li ng-click="form.goTo(Form, 1)">
      <a href ng-class="{'selected' : currentStep >= 1, 'done' : currentStep > 1}">
        <div class="stepNumber">
        </div> <span class="stepDesc text-small">Question No {{$index}}</span>
      </a>
    </li>
  </div>
</div>