我在我的项目中使用下面的结构表格。
**<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**
@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>;