最佳答案
下面是如何使用 Angular Material 数据表在 Angular 应用程序中实现 mat-paginator 的说明。
.html
<mat-paginator [pageSize]="pageSize" [pageIndex]="pageNo"
[pageSizeOptions]="[5, 10, 25, 100]" (page)="pageEvents($event)">
</mat-paginator>
.ts
import { MatPaginator } from '@angular/material';
@ViewChild(MatPaginator, { static: true})
paginator: MatPaginator;
pageSize: number;
pageNo: number;
ngOnit() {
this.pageSize = 10;
this.pageNo = 0;
}
pageEvents(event: any) {
console.log(event.pageIndex);
console.log(event.pageSize);
if(event.pageIndex > this.pageNo) {
// Clicked on next button
} else {
// Clicked on previous button
}
// The code that you want to execute on clicking on next and previous buttons will be written here.
}
关于angular - 如何知道是否单击了垫分页器的下一个或上一个按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59850607/