异步调用的DirPagination在angular js中不起作用

时间:2019-01-30 20:28:30

标签: angularjs dirpagination

我正在使用dirPagination填充表,我从angularJS控制器动态设置了总项目和当前页面,Aysnchronous调用正确填充了第1页的数据,但是当我单击第2页时,API调用返回了下一组结果,第2页高亮显示,并且日期设置为数组,但数据未显示在UI中。

<!--This is my 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>

<!--This is dirPagination Controller-->
<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">                                
</dir-pagination-controls>`

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

0 个答案:

没有答案