I want to iterate over a list, for example:
$scope.articles = [ { id: 1, name: "Pizza Vegetaria", price: 5 }, { id: 2, name: "Pizza Salami", price: 5.5 }, { id: 3, name: "Pizza Thunfisch", price: 6 } ]; If I iterate over this list a second time with another ng-repeat, I want the $index to be continued instead of starting from the beginning. So is it possible to pass the index from one ng-repeat scope to another? So instead of getting this result:
0 Pizza Vegetaria 5 1 Pizza Salami 5.5 2 Pizza Thunfisch 6 0 Pizza Vegetaria 5 1 Pizza Salami 5.5 2 Pizza Thunfisch 6 I'd like to have this result:
0 Pizza Vegetaria 5 1 Pizza Salami 5.5 2 Pizza Thunfisch 6 3 Pizza Vegetaria 5 4 Pizza Salami 5.5 5 Pizza Thunfisch 6 The HTML looks like the following:
<table class="table"> <tr ng-repeat="article in articles track by $index"> <td>{{$index}}</td> <td>{{article.name}}</td> <td>{{article.price}}</td> </tr> </table> <table class="table"> <tr ng-repeat="article in articles track by $index"> <td>{{$index}}</td> <td>{{article.name}}</td> <td>{{article.price}}</td> </tr> </table> Thanks in advance!