Javascript 更新NgModel时,视图不更新

Javascript 更新NgModel时,视图不更新,javascript,angular,angular-material,Javascript,Angular,Angular Material,在我的代码中,我使用子组件中的EventEmitter更新父组件home 调用函数this.getPrismClientLocatorExceptions()时,会更新ngModel、this.tableData,但视图中的表不会使用新数据更新。如何让视图更新或让childComponent检测此更改 导入{ 来自“@angular/core”的组件,输入,OnInit}; 从'@angular/Http'导入{Http,Headers}; 从'@angular/Router'导入{Route

在我的代码中,我使用子组件中的EventEmitter更新父组件home

调用函数this.getPrismClientLocatorExceptions()时,会更新ngModel、this.tableData,但视图中的表不会使用新数据更新。如何让视图更新或让childComponent检测此更改

导入{
来自“@angular/core”的组件,输入,OnInit};
从'@angular/Http'导入{Http,Headers};
从'@angular/Router'导入{Router,ActivatedRoute};
从“../../Services/ClientService.service”导入{ClientService};
从“../table/table.component”导入{TableComponent};
//ReSharper禁用一次TsResolvedFromInaccessibleModule
@组成部分({
选择器:“主页”,
templateUrl:“./home.component.html”,
样式URL:['./home.component.css'],
提供者:[客户端服务]
})
导出类HomeComponent实现OnInit{
列:字符串[]=['prismClientName','officeName','control\u Cmpy\u NM','exceptionType','id'];
@Input()tableData:PrismClientGrid[];
构造函数(公共http:http,私有路由器:路由器,私有客户端服务:客户端服务){}
恩戈尼尼特(){
this.getPrismClientLocatorExceptions();
}
getPrismClientLocatorExceptions(){
返回此。\u clientService.GetPrismClientLocatorExceptions().subscribe((数据)=>{
this.tableData=data.json()为PrismClientGrid[];
});
}
onDeleted(已删除:布尔值){
this.getPrismClientLocatorExceptions();
}
}
接口PrismClientGrid{
prismClientName:字符串;
officeName:string;
例外类型:字符串;
控制Cmpy\U NM:字符串;
合同编号:编号;
prismClientID:编号;
}

$('.dropdown toggle').dropdown()
按办公室列出的客户例外情况

@AnkitSharma ngOnChanges需要更新表格数据

下面是我实现的ngOnChanges函数,用于让数据源重新加载并正确显示数据

ngOnChanges(更改:SimpleChanges):无效{
this.dataSource=新MatTableDataSource(changes.data.currentValue);
this.dataSource.paginator=this.paginator;
this.dataSource.sort=this.sort;

}
我能想到的是,您在
ngOnInit
上只分配了一次
tableData
。另一次调用时,可能会有一个新的
tableData
,但
dataSource
指向在ngOnInit上初始化的旧对象。请尝试
ngOnChanges
并初始化
dataSource
一次
tableData
更改。让我知道结果。我会说,尝试对表组件使用双向数据绑定检查此链接: