Skip to content

Commit

Permalink
Prevent watch on totalPages from clobbering non-first page initializa…
Browse files Browse the repository at this point in the history
…tion

Fix for angular-ui#2108
  • Loading branch information
twhitman committed Apr 24, 2014
1 parent 7899b12 commit 39ccdbe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pagination/pagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ angular.module('ui.bootstrap.pagination', [])
$scope.totalPages = self.calculateTotalPages();
});

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

if ( $scope.page > value ) {
if ( $scope.page > value && value != oldvalue ) {
$scope.selectPage(value);
} else {
ngModelCtrl.$render();
Expand Down

2 comments on commit 39ccdbe

@codewithcats
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix works for me. Thank you @twhitman :)

@twhitman
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tnwt7 glad it helped you out!

Please sign in to comment.