Assume the following object
var items [
{ type: 'big', .... },
{ type: 'small', .... },
{ type: 'big', .... },
{ type: 'small', .... },
{ type: 'big', .... },
];
Which I use inside a ng-repeat as follows:
<div ng-repeat="item in items">
<span ng-if="item.type === 'big'>{{$index}}</div>
<p> ..... </p>
</div>
The problem with this code is that I only want to number the items with type === 'big' and I don't wan't gapes in the numbering. The output now is:
<div>
<span>0</div>
<p>......</p>
</div>
<div>
<p>......</p>
</div>
<div>
<span>2</div> // I want a 1 here
<p>......</p>
</div>
<div>
<p>......</p>
</div>
<div>
<span>4</div> // and a 2 here!
<p>......</p>
</div>
What would be the angular way to perform this kind of numbering ?