This repository has been archived by the owner. It is now read-only.
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upChange totalPages watcher to avoid resetting page number before data loa... #3085
Conversation
…loads If data is being loaded asyncronously but the page number is already known then pagination will update page number to 1 initially before ajax data comes back, and it will stay on page 1 instead of the page originally intended. e.g. if $scope.currentPage = 2; then <pagination ng-model="currentPage" ng-change="changed" .... ></pagination> will update $scope.currentPage to 1 when the view loads initially (no data = 1 page) and fire the change handler, putting the user back on page 1.
| @@ -54,6 +54,8 @@ angular.module('ui.bootstrap.pagination', []) | |||
| }); | |||
|
|
|||
| $scope.$watch('totalPages', function(value) { | |||
| if(!$scope.totalPages) | |||
This comment has been minimized.
This comment has been minimized.
|
Can you also add a unit test for this? |
ovarunendra
commented
May 8, 2015
|
+1 |
|
This should now be fixed in |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
synapscommerce commentedDec 10, 2014
...ds
If data is being loaded asyncronously but the page number is already known then pagination will update page number to 1 initially before ajax data comes back, and it will stay on page 1 instead of the page originally intended.
e.g. if $scope.currentPage = 2; then <pagination ng-model="currentPage" ng-change="changed" .... > will update $scope.currentPage to 1 when the view loads initially (no data = 1 page) and fire the change handler, putting the user back on page 1.