Answer the question
In order to leave comments, you need to log in
Angular MatPaginator - two tables in one component, paginators conflict?
If I add a second MatTable to the page, their paginators start to conflict
export class StatsComponent implements OnInit {
dataSource_us: MatTableDataSource<any>;
@ViewChild(MatPaginator, {static: true}) paginator_us: MatPaginator;
dataSource_tr: MatTableDataSource<any>;
@ViewChild(MatPaginator, {static: true}) paginator_tr: MatPaginator;
getStats() {
this.statsService.getStats().subscribe((data: any) => {
// Здесь формируется первая таблица
this.dataSource_us = new MatTableDataSource(ustable);
this.dataSource_us.paginator = this.paginator_us;
// Здесь формируется вторая таблица
// И отсюда начинаются проблемы - в обоих таблицах спутывается пагинация
this.dataSource_tr = new MatTableDataSource(trtable);
this.dataSource_tr.paginator = this.paginator_tr;
</table><mat-paginator [pageSizeOptions]="[2, 5, 30]" showFirstLastButtons></mat-paginator>
</table><mat-paginator [pageSizeOptions]="[10, 20, 30]" showFirstLastButtons></mat-paginator>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question