0

i have a problem in indexing with ng-repeat

   <tr ng-repeat="Ward in Wardresult ">
        <td>{{$index + 1}}</td>
         ......................
            some column
        .......................
     </tr>   

but in output result in index is

Sr 1 10 11 12 13 . . . 2 3 4

how can i solve this problem i use ng-init and also i take index in JS ,convert into int but result is in same format.

2
  • <table> <tr ng-repeat="Ward in Wardresult"> <td>{{$index + 1}}</td> </tr> </table> it works ,please post your full code Commented May 29, 2017 at 8:24
  • post more code, because it works in this fiddle Commented May 31, 2017 at 14:22

1 Answer 1

1

Please Use track by $index

Code :

<div ng-repeat="Ward in Wardresult track by $index" >
      {{$index + 1}}
    </div>

Working Demo

Sign up to request clarification or add additional context in comments.

3 Comments

i did this , but stil result is in 1,10,11,12, ... format
actually i am taking data from database and store in Wardresult .
i tried all the posible ways to solve this problem but i think there is some problem with ng-repeat .It take all valueas as string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.