在我的应用程序中的所有角度材料表中,每个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。 似乎找不到任何答案
我尝试了这个解决方案,它奏效了。
import { TemplateModule } from '@template/template.module';
imports: [ /* Other imported modules */ TemplateModule ], exports: [ /* Other exported modules */ TemplateModule ]
确保停止亮起的服务器或关闭Visual Studio Code并再次打开它。