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

uib-pagination initial current page #5858

Closed
amilcar-calles opened this issue Apr 29, 2016 · 10 comments
Closed

uib-pagination initial current page #5858

amilcar-calles opened this issue Apr 29, 2016 · 10 comments

Comments

@amilcar-calles
Copy link

amilcar-calles commented Apr 29, 2016

Bug description:

  • When I give an initial value into the uib-pagination the value is changed to 1, even if the original value was another.

Code that reproduces the issue:

Example:

JS:
angular.controller('myController', function() { this.pager = { currentPage: 3 } })

HTML
<uib-pagination ng-model="vm.pager.currentPage"></uib-pagination>

Then the value in vm.pager.currentPage will be changed to 1 automatically when the controller starts.

Version of Angular, UIBS, and Bootstrap

Angular: 1.5.0

UIBS: 0.14.3

Bootstrap: 3.1.1

@wesleycho
Copy link
Contributor

Please post a Plunker reproduction - this should already be fixed as this is a duplicate of #2956.

@wesleycho
Copy link
Contributor

Going to close this as fixed - the fix is in 1.0.0, but not 0.14.3.

@jay-gandhi
Copy link

jay-gandhi commented Aug 10, 2016

Hi, I'm using 2.0.1 and I'm putting page number in query string and UIB-pagination changes to value to 1.

http://localhost:9000/emailtrack/?Page=4

but it's changing to

http://localhost:9000/emailtrack/?Page=1

@wesleycho
Copy link
Contributor

If there is a legitimate issue, please post a minimal reproduction in Plunker in a separate issue.

@samzhao2008
Copy link

@jay-gandhi
+1

@pc3b3r
Copy link

pc3b3r commented Nov 24, 2016

I had the same problem and I solved in this way:

  1. use ng-click instead of ng-change
  2. set your page model after total-items has been set

@daric81
Copy link

daric81 commented Dec 19, 2016

I was having the same issue after moving from v 0.13.x to 1.3.3. Setting the total items after the current page used to work.

I used the solution from @pc3b3r to get round the problem.

@kostalihas
Copy link

use in the template <ul uib-pagination total-items="totalPages" ng-model="pagination.currentPage" ng-change="pageChanged()" items-per-page="20" max-size="5" boundary-links="true"></ul>
and in your controller
$scope.pagination = {currentPage: 1 }; $scope.loadMovies = function(){ serviceAjax.popular($scope.pagination.currentPage).then(function(data){ $scope.movies = data.data.results; $scope.totalPages = data.data.total_pages; }); }; $scope.pageChanged = function(){ $scope.loadMovies(); };

@a2f0
Copy link

a2f0 commented Sep 5, 2017

I am experiencing this issue with 2.5.0.

@bzashev
Copy link

bzashev commented Nov 5, 2017

The trick that helped me is to initialize the totalPages variable with a number bigger than the page size. I used 1000. This will not reset the current page. Hope that helps you too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

8 participants