I am using ui-Bootstrap pagination but its not working as expected I refer following post but its not working for me.
How do I tell ui-Bootstrap what content to paginate?
My code is as follows.
<div>
<ul>
<li ng-repeat= "payment in paymentHistory">
<div >
<div >
<p >payment.status</p>
</div>
<div>
<p >payment.cost</p>
</div>
</div>
</li>
</ul>
</div>
<div ng-show="pagination"> <pagination total-items="totalItems" items-per-page="itemsPerPage" ng-model="currentPage" ng-change="pageChanged()"></pagination></div>
My controller code:
paymentFactory.getPaymentHistory( )
.success(function (paymentHisInfo) {
for(var i = 0; i< paymentHisInfo.list.length; i++){
$scope.paymentHistory.push({
"status":paymentHisInfo.list[i].status,
"cost":paymentHisInfo.list[i].cost});
}
$scope.list = $scope.paymentHistory;
$scope.itemsPerPage = 5;
$scope.currentPage = 1;
$scope.pageCount=Math.ceil($scope.list.length / $scope.itemsPerPage);
$scope.list.$promise.then(function () {
$scope.totalItems = $scope.list.length;
var begin = (($scope.currentPage - 1) * $scope.itemsPerPage),
end = begin + $scope.itemsPerPage;
$scope.paymentHistory = $scope.list.slice(begin, end);
});
})
.error(function(){
console.log("error occured in getPaymentHistory");
});
Please let me know whats wrong in my code