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

fix(pagination): fixes issue when init called after watch triggered #2257

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/pagination/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@ angular.module('ui.bootstrap.pagination', [])
} else {
this.itemsPerPage = config.itemsPerPage;
}

$scope.$watch('totalItems', function() {
$scope.totalPages = self.calculateTotalPages();
});

$scope.$watch('totalPages', function(value) {
setNumPages($scope.$parent, value); // Readonly variable

if ( $scope.page > value ) {
$scope.selectPage(value);
} else {
ngModelCtrl.$render();
}
});
};

this.calculateTotalPages = function() {
Expand Down Expand Up @@ -48,20 +62,6 @@ angular.module('ui.bootstrap.pagination', [])
$scope.noNext = function() {
return $scope.page === $scope.totalPages;
};

$scope.$watch('totalItems', function() {
$scope.totalPages = self.calculateTotalPages();
});

$scope.$watch('totalPages', function(value) {
setNumPages($scope.$parent, value); // Readonly variable

if ( $scope.page > value ) {
$scope.selectPage(value);
} else {
ngModelCtrl.$render();
}
});
}])

.constant('paginationConfig', {
Expand Down