垫子问题

问题描述 投票:0回答:1

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

**<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个回答
0
投票

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

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

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

OR

您可以使用@ViewChildren代替@ViewChild

@ViewChildren(MatPaginator) paginators: QueryList<MatPaginator>;

© www.soinside.com 2019 - 2024. All rights reserved.