question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I set pageIndex of paginator and it can update itself?

See original GitHub issue

Bug, feature request, or proposal:

proposal

What is the expected behavior?

For example. When the paginator display 11-20 of 400 , I want to set the pageIndex to initial state. And after that, I want paginator display 1-10 of 400.

What is the current behavior?

First page is 0 and current page is 1, the paginator view display 11-20 of 400.

I set the pageIndex to initial state like this:

this.paginator.pageIndex = 0;

But the view of paginator not update. Still display 11-20 of 400.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

"@angular/core": "^4.3.1", "@angular/material": "^2.0.0-beta.8",

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
maskalekcommented, Aug 21, 2019

MatPaginator contains method to move to the first page.

this.paginator.firstPage()

3reactions
srokatoniecommented, May 13, 2018

Full solution:

You need to declare paginator dom element as variable using #paginator

<!-- my.component.html -->
<mat-paginator #paginator></mat-paginator>

Then set every time you need to set pageIndex:

//my.component.ts
this.paginator._pageIndex = 0;
Read more comments on GitHub >

github_iconTop Results From Across the Web

reset paginator first page angular material - Stack Overflow
You need to use a ViewChild decorator to select the paginator and then set the pageIndex property of the paginator.
Read more >
Paginator | Angular Material
When the user interacts with the paginator, a PageEvent will be fired that can be used to update any associated data view.
Read more >
Data Table Pagination using Angular Material - Medium
When the user interacts with the paginator, a PageEvent will be fired that can be used to update any associated data view. Page...
Read more >
A Demo On Angular(v12) Pagination Using Angular Material ...
In this article, we are going to implement pagination using angular material in a sample angular(version 12) application.
Read more >
simplemattable - npm
A simplified, declarative table-library using @angular/material's MatTable with form capabilities for adding/editing/deleting data.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found