Hi here i have a class as
export class Employeemodel {
constructor() {
this.name = "";
this.gender = 0;
}
name: string;
gender: number;
}
When i try to Bind data to This Class as
// EmployeeService.ts
GetData<T>(pagenum:number) {
return this
.http
.get<Employeemodel[]>(this.apiUrl+'GetPagination/'+pagenum)
.pipe(tap(data => {
}));
}
// EmployeeComponent.ts
GetPagination(PageNo: number) {
this._oservices
.GetData(PageNo)
.subscribe((result: Employeemodel[]) => {
this.dataSource = new MatTableDataSource(result.otestgrid);
});
}
result.otestgrid Getting Error as Property 'otestgrid' does not exist on type 'Employeemodel[]'.
My Service call Giving Me output as
{
"otestgrid": [
{
"name": "Dastageer",
"gender": 1,
"distName": "Hyderabad",
"otestBindata": null
},
}
this._oservices.GetData(PageNo)function in your questionsubscribe((res:any)=> {..}or create an interface with the model of the response