【发布时间】:2021-01-11 16:04:17
【问题描述】:
我已经在服务器中部署了我的 Angular 应用程序。经过多次测试,我发现Angular Material表没有显示任何数据,而您在日志中看不到数据。
我只是在生产中遇到这个问题,在开发中一切都很好。
数据将从数据库发送。
可以清楚地看到,有数据但没有显示出来。
我的 HTML 文件:
<table mat-table [dataSource]="dataSource">
<ng-container matColumnDef="CODE">
<th id ="n" mat-header-cell *matHeaderCellDef>Code</th>
<td mat-cell *matCellDef="let element">{{element.CODE}}</td>
</ng-container>
<ng-container matColumnDef="NAME">
<th id="typeLien" mat-header-cell *matHeaderCellDef>Nom</th>
<td mat-cell *matCellDef="let element">{{element.NAME}}</td>
</ng-container>
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
<tr mat-row *matRowDef="let element; columns: displayedColumns;"></tr>
</table>
我的 TS 文件:
this.communicationService.getArticles().toPromise().then(allArticles=> {
this.dataSource = new MatTableDataSource(allArticles);
this.dataSource.paginator = this.paginator;
});
【问题讨论】:
标签: angular typescript angular-material mat-table