【发布时间】:2020-12-07 16:52:45
【问题描述】:
您好,我在我的 mat-table 中过滤了大约 6000 行数据,当单击“过滤器”按钮时,过滤需要大约 5 秒。我试图在调用函数时显示一个 Mat-Progress-Bar。我附上了一个示例 stackblitz 来尝试重现我的问题。我希望 Mat-Progress-Bar 仅在单击“过滤器”按钮时显示,并在呈现数据时消失。
https://stackblitz.com/edit/angular-4ttand-8ckvs7?file=src/app/table-basic-flex-example.ts
<button mat-raised-button (click)="filterTable()"> Filter Table on Weight!</button>
<mat-progress-bar *ngIf="isLoading" color="primary" mode="indeterminate"></mat-progress-bar>
export class TableBasicFlexExample {
isLoading = true
filterTable() {
this.dataSource = this.dataSource.filter((item) => {
return Math.floor(item.weight) > 10});
this.isLoading = false;
}
}
【问题讨论】: