Skip to content

DirPagination for asynchronous call not working in angular js #477

Description

@nikileshgowda

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) {
        };
    });
} 
```

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions