【发布时间】:2019-05-19 22:43:49
【问题描述】:
我正在开发 Angular 5,我在更新 mat-table(Angular Material 数据表)时遇到了问题。
有 2 个独立组件(没有父子组件)我正在更改一个组件中下拉列表的值,并尝试根据该值从数据库中获取值,从而更新数据表。
在调试时发现更新的数据来自数据库,但在数据表中看不到任何更新。
可能有一些与 mat-table 相关的问题,但不确定。
提前致谢。
下面是我用来从数据库中获取数据并绑定数据表的代码。
async GetFileHistoryDataBasedOnRole(selectedRole: string) {
let fileHistoryDataBasedOnRole: any = await this.fileHistoryService.FetchFileHistoryDataBasedOnRole(selectedRole);
if (fileHistoryDataBasedOnRole != undefined && fileHistoryDataBasedOnRole != null) {
fileHistoryDataBasedOnRole = JSON.parse(fileHistoryDataBasedOnRole.toString());
this.dataSource = new MatTableDataSource(fileHistoryDataBasedOnRole);
this.dataSource.paginator = this.paginator;
this.dataSource.sort = this.sort;
}
}
【问题讨论】:
标签: angular datatable angular-material