首页 > 解决方案 > 数据不可用时如何在表格上显示消息

问题描述

我创建了内联可编辑表。当数据不可用时,它应该“无记录显示。但我无法显示它。我试过这个:

<ng-template #viewable>
  <ng-container *ngIf="data && data.length > 0; else noDataToShow">
    <ng-container *ngFor="let head of headers">
      <ng-container *ngIf="head.mappedProperty">
        <td>
          {{ head.dataType ==='dropDown' ? tableData[head.mappedName]: head.dataType ==='date' ?
          (tableData[head.mappedProperty] | date: 'dd-MM-yyyy') : tableData[head.mappedProperty] }}
        </td>
      </ng-container>
    </ng-container>
  </ng-container>
  <ng-template #noDataToShow> No Data to Show </ng-template>
</ng-template>

标签: javascripthtmlangulartypescript

解决方案


一种可能的解决方案*matNoDataRow

<tr class="mat-row" *matNoDataRow>
  <td class="mat-cell" colspan="9999">
    No record display.
  </td>
</tr>

推荐阅读