Showing posts with label pagination. Show all posts
Showing posts with label pagination. Show all posts

Thursday, July 30, 2015

Adding pagination functionality in table using AngularJS

AngularJS (v 1.4) provides limito  filter to create a new array with specified number of elements out of existing array. It also supports from which index you want to create a new array.

you may read more about the filter from the following URL:

https://code.angularjs.org/1.4.0/docs/api/ng/filter/limitTo

Ex:

{{ sample_array | limitTo : numberofelement_perpage : startingrowno}}
where in my controller :

$scope.sample_array=["elem1","elem2","elem3","elem4","elem5","elem6","elem7","elem8","elem9","elem10"];
$scope.numberofelement_perpage=5;
$scope.startingrowno=0;
Using above filter we can create client side pagination in HTML table.


Following Plnukr shows the usage of limitito and begin to create client side pagination in HTML table.

http://plnkr.co/edit/tWFUPm?p=preview