首页 > 解决方案 > 角度材料表错误:“...MatCellDef 未定义隐式值”

问题描述

在我的应用程序中的所有 Angular Material 表中,每个 td 标签和底部 tr 标签都有一个错误

'MatCellDef' 的模板上下文没有定义隐式值。如果上下文类型是基本类型,请考虑将其细化为更具体的类型。

桌子:

<table mat-table matSort [dataSource]="businessLocations">    
  <ng-container matColumnDef="business_city">
   <th mat-header-cell mat-sort-header *matHeaderCellDef> City </th>
   <td mat-cell *matCellDef="let location">{{location.business_city}}</td>
  </ng-container>

  <tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
  <tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
</table>

一些 TS:

 this.businessLocations = response.businessLocations;
 this.businessLocations =  new MatTableDataSource(this.businessLocations);

如果需要,我可以提供更多代码。我正在使用带有 Angular Essentials 插件的 Visual Studio Code。似乎无法找到任何答案

标签: angularvisual-studioangular-material

解决方案


推荐阅读