【问题标题】:Mat Paginator issue垫分页器问题
【发布时间】:2020-01-17 20:46:44
【问题描述】:

我在我的项目中使用下面结构的垫表。

**<mat-paginator></mat-paginator>
<mat-table></mat-table>
<mat-paginator></mat-paginator>**

In my ts file look like

 **@ViewChild(MatPaginator) paginator: MatPaginator;**


 **Actual problem is first one paginator is working fine and trigger events correctly.
 bottom mat paginator is not working and event is not triggered ,also page,pageIndex is not 
refelecting from first paginator**

【问题讨论】:

    标签: angular7


    【解决方案1】:

    @ViewChild 只查询一个组件引用。但是您认为有两个组成部分。因此,您必须分别查询这两个组件,如下所示。

    <mat-paginator #topPageinator></mat-paginator> <mat-table></mat-table> <mat-paginator #bottomPageinator></mat-paginator>

    @ViewChild('topPageinator') paginator: MatPaginator; @ViewChild('bottomPageinator') paginator: MatPaginator;

    您可以使用@ViewChildren 代替@ViewChild

    @ViewChildren(MatPaginator) paginators: QueryList&lt;MatPaginator&gt;;

    【讨论】:

    • 以上两个解决方案都不起作用,也没有触发事件
    • 能分享下view(html文件)和逻辑(ts文件)的具体代码吗?
    猜你喜欢
    • 2021-02-08
    • 2021-11-04
    • 1970-01-01
    • 2023-02-15
    • 2010-12-04
    • 2021-04-03
    • 2020-06-19
    • 1970-01-01
    • 2018-07-08
    相关资源
    最近更新 更多