我在我的项目中使用下面的结构垫表。
**<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**
发布于 2020-01-17 12:46:45
@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<MatPaginator>;
https://stackoverflow.com/questions/59781834
复制