【发布时间】:2021-03-30 01:04:39
【问题描述】:
我有一个基于页码获取的 API,如何将在下一个和上一个按钮上更改的表页面索引发送到此 API 请注意我创建了一个共享表
@Input() columns: Column[] = [];
@Input()rows!: Row<T>[];
@ViewChild(MatSort, { static: true }) matSort!: MatSort;
@ViewChild(MatPaginator, { static: false }) matPaginator!: MatPaginator;
@Input() isPageable = false;
@Input() paginationSizes: number[] = [5, 10, 15];
@Input() defaultPageSize = this.paginationSizes[1];
pageNo = 0;
@Input() PageIndex = 0;
public dataSource = new MatTableDataSource<Row<T>>();
public columnNames: string[] = []
constructor(private cd: ChangeDetectorRef) { }
ngOnInit(): void {
this.dataSource.data = this.rows;
this.columnNames = this.columns.map((column) => column.name.toString());
this.dataSource.paginator = this.matPaginator;}
ngAfterViewInit(): void {
this.dataSource.paginator = this.matPaginator;}
pageEvents(event: any) {
console.log("PageIndex " + "=" + event.pageIndex);
if (event.pageIndex > this.pageNo) {
this.PageIndex = event.pageIndex
console.log(this.PageIndex)
【问题讨论】:
标签: angular typescript pagination angular-material mat-table