重置分页器第一页角材料 [英] reset paginator first page angular material
本文介绍了重置分页器第一页角材料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试转到mat-paginator的第一页,即重置分页,但不起作用.知道如何解决吗?
I am trying to go to the first page of the mat-paginator, that is, reset the pagination, but it does not work. Any idea how it can be solved?
我的 html 是这样的
My html is such that
<mat-paginator [length]="itemTotal" [pageIndex]="page" [pageSize]="itemPage" (page)="pageEvent = getPublicationFollowersData($event)">
</mat-paginator>
打字稿:
getPublicationFollowersData(event?: PageEvent) {
this.getPublicationsUser(event.pageIndex);
}
我尝试使用以下命令初始化页面:
and i try to initialize the page with:
this.page = 1
但它不起作用.
推荐答案
您需要使用 ViewChild
装饰器来选择分页器,然后设置分页器的 pageIndex
属性分页器.
You need to use a ViewChild
decorator to select the paginator and then set the pageIndex
property of the paginator.
@ViewChild() paginator: MatPaginator;
...
this.paginator.pageIndex = 0;
正如其他答案所建议的,如果您想将分页器重置为第一页,最好使用 this.paginator.firstPage()
As suggested by the other answers, if you would like to reset the paginator to the first page, it would be better to use this.paginator.firstPage()
这篇关于重置分页器第一页角材料的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文