Reputation: 179
I would create a pagination of data taken with $http call. So I would make something like that:
<ul class="pagination">
<li ng-repeat="xxxxxx"><a href="/detail.php?PAGE={{n}}">{{n}}</a></li>
</ul>
What I've to put into ng-repeat to show all pages of record from 1 to {{totalPage}}?
Upvotes: 0
Views: 41
Reputation: 14590
You need to have the total number of items and the page size then, in Angular:
var items = //your factory/service results
var num = items.length;
var pageSize = 10;
$scope.pages = ((num/10)+1).toFixed(0);
$scope.range = function(min, max, step){
step = step || 1;
var input = [];
for (var i = min; i <= max; i += step) input.push(i);
return input;
};
And in the HTML:
<ul class="pagination">
<li ng-repeat="n in range(1, pages)"><a ng-href="/detail.php?PAGE={{n}}">{{n}}</a></li>
</ul>
EDIT: Updated with jsfiddle http://jsfiddle.net/s9kfwgbr/
Upvotes: 1