AngularJS pagination

rashmitha r 21 Reputation points
2022-07-16T18:21:30.17+00:00

I want to simple pagination for my table in angular, following is my html code,

<tr ng-repeat="e in LeaveApplyDataSource.slice((currentPage -1) * pageSize, currentPage * pageSize)"> <td>{{e.LeaveType}}</td> <td>{{e.StringFromDate}}</td> <td> <span class="badge badge-success">{{e.Status}}</span> </td></tr>

<button ng-disabled="currentPage == 0" ng-click="currentPage=currentPage-1"> Previous </button> Page {{currentPage+1}} of {{numberOfPages()}} <button ng-disabled="currentPage >= data.length/pageSize - 1" ng-click="currentPage=currentPage+1"> Next </button>

And here's my angular code,
$scope.currentPage = 0;
$scope.pageSize = 10;
$scope.numberOfPages = [];
$scope.data = [];
$scope.LoadData();
$scope.numberOfPages = () => {
return Math.ceil(
$scope.LeaveApplyDataSource.length / $scope.pageSize
);
}
for (var i = 0; i < $scope.LeaveApplyDataSource.length; i++) {
$scope.data.push($scope.LeaveApplyDataSosurce);
}
In $scope.LeaveApplyDataSosurce all data is loading, but it is not displaying any data in my table but if i give ' $scope.currentPage' is 1 then one page is displaying properly but it begins with 2nd page with 10 values, other data is not displaying . What is the issue? please suggest me any simple angular pagination.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,251 questions
{count} votes