尝试绑定来自JSON-SERVER的数据错误:无法找到id为" modulen"的列
测试数据
{
"modules": [
{
"Id": 0,
"ModuleNm": "Visa",
"UploadDttm": "01/14/2019 21:27",
},
{
"Id": 0,
"ModuleNm": "Visa",
"UploadDttm": "01/14/2019 21:28",
},
]
<我的接口/strong>
export interface IModuleType {
modules: Module[];
}
export interface Module {
Id: number;
ModuleNm: ModuleNm;
UploadDttm: string;
}
loadData(selectedModuleType: string): Observable<any>{
return this._http.get<IModuleType[]>(this.testData );
}
<组件/strong>
displayedColumns: string[] = ['ModuleNm', 'UploadDttm',];
dataSource!: MatTableDataSource<IModuleType>;
getData(selectedModule: string): void {
console.log('loadModuleData mothod :::::>', selectedModule);
this.test.loadData(selectedModule).subscribe({
next: (resp) => {
console.log('RESPONSE IN COMPONENT', typeof resp, resp); // getting object
this.dataSource = resp;
},
error: (err: any) => {
console.log('Errors :::>', err);
},
complete: () => {
console.log('request completed');
},
});
}