-2

I want to implement a pagination into my large ng-repeat, because the rendering of 200 objects is to slow.

I want to use the bootstrap-ui pagination.

Based on the selected page I will calculate which object will be displayed. But in my ng-repeat i have no index. So my initial plan doesn't work. for example:

<div ng-if="index >= min && index <= max">
 ... show this object...
</div>

Can someone help me how to solve this problem?

thank you!

user2622344
  • 956
  • 1
  • 10
  • 26
  • 8
    You can use `$index`. This is mentioned in the very first paragraph of the [`ng-repeat` docs](https://docs.angularjs.org/api/ng/directive/ngRepeat). – James Allardice May 29 '15 at 12:46
  • possible duplicate of [Finding an ng-repeat index?](http://stackoverflow.com/questions/22584219/finding-an-ng-repeat-index) – Aurelio May 29 '15 at 12:48
  • See the very first part of this: https://code.angularjs.org/1.3.15/docs/api/ng/directive/ngRepeat – Mike Cheel May 29 '15 at 12:48

1 Answers1

1

Angularjs provides $index on local scope of each template instance - iterator offset of the repeated element (0..length-1). https://docs.angularjs.org/api/ng/directive/ngRepeat

<div ng-repeat="(key, value) in myObj">
    <div ng-if="$index >= min && $index <= max">
        ... show this object...
    </div>
</div>
softvar
  • 17,917
  • 12
  • 55
  • 76