michaelbromley / michaelbromley/angularUtils
DirPagination for asynchronous call not working in angular js
- Dominant language
- JavaScript
- Stars
- 2k
- Forks
- 842
- PR merge metrics
- No merged PRs in 30d
Description
I'm using dirPagination to populate table, I have set total-items and current-page dynamically from angularJS controller, Aysnchronous call populates data correctly for page 1, but when i click on page 2 API call returns next set of result, Page 2 is higlighted and date is set to array but data not displaying in UI.
```
//In Controller
$scope.pageSize = 5;
$scope.totalItems = 0;
var start = 0;
var max = 5;
$scope.currentPage = 1;
$scope.pageChanged = pageChanged;
function pageChanged(pageNum) {
if (pageNum == 1) {
start = 0;
$scope.policyList = [];
} else {
start = max * (pageNum - 1);
}
$scope.currentPage = pageNum;
getList();
}
//getList function
$scope.getList = getList;
function getList() {
$scope.parameter.pageNumber = $scope.currentPage;
$scope.parameter.itemsPerPage = max;
var result =
homeService.getList($scope.parameter);
result.then(function (success) {
$scope.List = success.data.resultList;
}, function (error) {
};
});
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the issue with the shown dir-paginate markup and controller, then inspect pageChanged and the getList promise callback while moving from page 1 to page 2. Done means the asynchronously returned resultList is rendered in the table after changing pages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angularjs
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100