Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 26b4090

Browse files
pschuegrwesleycho
authored andcommitted
fix(pagination): fixes issue when init called after watch triggered
Ensure `$watch expressions are bound after init is called Closes #2257 Fixes #2227
1 parent 7de7a8e commit 26b4090

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/pagination/pagination.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,20 @@ angular.module('ui.bootstrap.pagination', [])
2121
} else {
2222
this.itemsPerPage = config.itemsPerPage;
2323
}
24+
25+
$scope.$watch('totalItems', function() {
26+
$scope.totalPages = self.calculateTotalPages();
27+
});
28+
29+
$scope.$watch('totalPages', function(value) {
30+
setNumPages($scope.$parent, value); // Readonly variable
31+
32+
if ( $scope.page > value ) {
33+
$scope.selectPage(value);
34+
} else {
35+
ngModelCtrl.$render();
36+
}
37+
});
2438
};
2539

2640
this.calculateTotalPages = function() {
@@ -48,20 +62,6 @@ angular.module('ui.bootstrap.pagination', [])
4862
$scope.noNext = function() {
4963
return $scope.page === $scope.totalPages;
5064
};
51-
52-
$scope.$watch('totalItems', function() {
53-
$scope.totalPages = self.calculateTotalPages();
54-
});
55-
56-
$scope.$watch('totalPages', function(value) {
57-
setNumPages($scope.$parent, value); // Readonly variable
58-
59-
if ( $scope.page > value ) {
60-
$scope.selectPage(value);
61-
} else {
62-
ngModelCtrl.$render();
63-
}
64-
});
6565
}])
6666

6767
.constant('paginationConfig', {

0 commit comments

Comments
 (0)