admin管理员组

文章数量:1331645

I have this codepen, and using the function '$scope.pageChanged' to see when a page is changed.

$scope.pageChanged = function() {
 $log.log('Page changed to: ' + $scope.currentPage);
};

But when I click on page links (changing a page), the variable '$scope.currentPage' doesn't changes. Why?

I think is something about the filter, but not sure.

I have this codepen, and using the function '$scope.pageChanged' to see when a page is changed.

$scope.pageChanged = function() {
 $log.log('Page changed to: ' + $scope.currentPage);
};

But when I click on page links (changing a page), the variable '$scope.currentPage' doesn't changes. Why?

I think is something about the filter, but not sure.

Share Improve this question asked Oct 16, 2015 at 23:54 robe007robe007 3,9474 gold badges38 silver badges61 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 10

Change

$scope.currentPage = 1;

to

$scope.pagination = {
    currentPage:  1
};

And as a consequence, it should be:

... pagination: pagination.currentPage
... ng-model="pagination.currentPage"
... $log.log('Page changed to: ' + $scope.pagination.currentPage);

You can group also other variables like maxSize in pagination. Avoid to bind primitives directly to the $scope.

Codepen

本文标签: javascriptscopecurrentPage not updatingAngular Ui PaginationStack Overflow