I have a dataset of about 1000 items in-memory and am attempting to create a pager for this dataset, but I\'m not sure on how to do this.
I\'m using a custom filter
I've had to implement pagination quite a few times with Angular, and it was always a bit of a pain for something that I felt could be simplified. I've used some of the ideas presented here and elsewhere to make a pagination module that makes pagination as simple as:
- {{ item }}
// then somewhere else on the page ....
That's it. It has the following features:
items
to the pagination links.ng-repeat
, so you can use any expression that could be validly used in an ng-repeat
, including filtering, ordering etc.pagination-controls
directive does not need to know anything about the context in which the paginate
directive is called.For those who are looking for a "plug and play" solution, I think you'll find this useful.
The code is available here on GitHub and includes a pretty good set of tests:
https://github.com/michaelbromley/angularUtils/tree/master/src/directives/pagination
If you are interested I also wrote a short piece with a little more insight into the design of the module: http://www.michaelbromley.co.uk/blog/108/paginate-almost-anything-in-angularjs/