Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DirPagination for asynchronous call not working in angular js #477

Open
nikileshgowda opened this issue Jan 30, 2019 · 0 comments
Open

DirPagination for asynchronous call not working in angular js #477

nikileshgowda opened this issue Jan 30, 2019 · 0 comments

Comments

@nikileshgowda
Copy link

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.

<!-- HTML code -->
<tr dir-paginate="item in List | orderBy:sortKey:reverse | 
filter:searchPolicy | itemsPerPage:pageSize track by $index"  total- items="totalItems" current - 
page="currentPage">
<td> </td>
<tr>

<dir-pagination-controls  max-size="10" ng-if="List!=null" 
on-page-change="pageChanged(newPageNumber)" 
template-url="tpl/dirPagination.tpl.html" direction-links="true" 
boundary-links="true">                                
```
//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) {
        };
    });
} 
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant