我制作了一个 MatTable,您可以在其中进行过滤。如果没有与过滤器匹配的数据,我想使用Angular Material 文档中提到的 * matNoDataRow指令显示文本。但是,它不像 Angular Material 的示例那样工作。有什么我忘记了吗?还是该指令尚未生效?我使用 Angular 9。
这是我的表:
<mat-form-field color="accent" appearance="fill" >
<mat-label >Filter</mat-label>
<input matInput (keyup)="doFilter($event.target.value)" placeholder="filter this table" (click)="searching=true" #input >
<button mat-icon-button matSuffix (click)="input.value=''; doFilter(''); searching= !searching" color="accent">
<mat-icon *ngIf="!searching">search</mat-icon>
<mat-icon *ngIf="searching">clear</mat-icon>
</button>
</mat-form-field>
<div class="sticky-container" style="margin-top: 2em;">
<table mat-table [dataSource]="dataSource" class="mat-elevation-z8" matSort matSortActive="EXPIRY DATE" matSortDirection="asc" matSortDisableClear>
<ng-container matColumnDef="id">
<th mat-header-cell *matHeaderCellDef mat-sort-header>CUSTOMER ID</th>
<td mat-cell *matCellDef="let customer; let i = index" class="no-outline"
routerLink="/summary/customer/{{customerService.id}}">{{customer.id}}</td>
</ng-container>
<ng-container matColumnDef="exDate">
<th mat-header-cell *matHeaderCellDef mat-sort-header>EXPIRY DATE</th> …Run Code Online (Sandbox Code Playgroud)