重置分页器首页角材料 [英] reset paginator first page angular material

查看:64
本文介绍了重置分页器首页角材料的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试转到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就是这样

<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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆