Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pagination. Default current page is 1 but documentation says 0 #1841

Closed
tamtakoe opened this issue Sep 11, 2017 · 3 comments
Closed

Pagination. Default current page is 1 but documentation says 0 #1841

tamtakoe opened this issue Sep 11, 2017 · 3 comments

Comments

@tamtakoe
Copy link

tamtakoe commented Sep 11, 2017

Because of default current page is 1 you can't ignore first loading. Furthermore you can't override it because any incorrect value is transformed to 1

if (page) {
 this.load(page); //always exist
}

Second question is why paginator calls pageChange callback with default page number after page was loaded?

http://plnkr.co/edit/VGeIFzcKzGeQV8MNGQus?p=preview


ng-bootstrap: v1.0.0-beta.4

@pkozlowski-opensource
Copy link
Member

I think that your main problem is that you are setting the collectionSize without setting page. If data comes dynamically (ex. collection comes from the server) you should set both values dynamically.

In other words, the pagination should be hidden or have no pages at all till the collection size is known.

Having said all the above I'm not clear from your description what is the practical use-case so hard to offer more info...

Second question is why paginator calls pageChange callback with default page number after page was loaded?

in this case page changes from undefined to 1.

@drewgreenwell
Copy link

Is this really a bug or just a documentation update? It seems like any invalid input to page should be set to 1. I'm anxious to get some of the other fixes in this milestone and would be willing to help out if something needs to be done, but this really doesn't seem like it warrants a bug in the framework.

@pkozlowski-opensource pkozlowski-opensource removed this from the 1.0.0-beta.6 milestone Nov 17, 2017
@maxokorokov
Copy link
Member

maxokorokov commented Mar 24, 2018

Docs need to be updated, the page can clearly never be zero, only 1 from a user perspective.
Plus the following case shouldn't fire at all IMO:

<!-- page stays undefined → OK -->
<ngb-pagination (pageChange)="page = $event"></ngb-pagination>

<!-- page = 1 → OK -->
<ngb-pagination [collectionSize]="20" (pageChange)="page = $event"></ngb-pagination>

<!-- page = 1 → should not fire as collection size is not set-->
<ngb-pagination [page]="5" (pageChange)="page = $event"></ngb-pagination>

Will open a PR with updates

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

No branches or pull requests

4 participants