i have a number of items generated using ng-repeat, i have to add pagination.but everywhere i can see by getting the count value of items, i can add. but i am not able to get using skip. i.e if the skip value is 10, it will skip the first items and list the other items,i need to do like using the skip value using angular-ui bootstrap.
following code inside services
mainEvents: function() {
var self = this;
var skipNumber=2;
return $http.get(UrlService.baseUrl + '/event/upcoming?count='+ skipNumber).then(function(response) {
// var events = response.data;
var events = response.data.events;
var upEvents=[];
var eventsLen = events.length;
for (var i = 0; i < eventsLen; i++) {
self.prepareForRendering(events[i]);
}
var totalItems = response.data.events.length;
angular.copy(response.data.events, upEvents)
console.log(upEvents);
// angular.copy(response.data.tracks, $scope.tracks)
return events;
}, function(response) {
return $q.reject(response.data.error)
});
},
$scope.pageChanged = function() {
mainEvents();
};
markup
<ul>
<li ng-repeat="event in events">{{event.name}}</li>
</ul>
<pagination total-items="totalItems" ng-model="skipNumber" ng-change="pageChanged()" items-per-page="1"></pagination>
Based on page number clicked,skipNumber to be incremented by 10, 20 etc.., How to do it.can anyone please help me
apiurl?skip=10it will skip first 10 items, for the first page skip should be 0, for the second page it should be 10 goes on like this. i want to display only 10 items at a timeng-modelwould actually be the page number so remove it from thepageChanged()method and either on your client site or on server site you need to multiply the current page number by the number of items per page to get the skip number.