I'm wanting to simply display each entry as a row in a html table, currently i get the following
Id id:1
taskFields:[object Object],[object Object], [object Object]
Instead i want to be able to see the values hidden in the object Object
I have an angular template of
<tr *ngFor="let entry of entries | keyvalue">
<td>{{entry.key}}:{{entry.value}}</td>
</tr>
In my component.ts file i have
ngOnInit():void{
this.entries = this.testService.getData().pipe((result) =>{
return result
}
In my testService i have
getData() : Observable<TestEntry[]>{
return this.httpClient.get<TestEntry[]>(this.baseUrl + '/api/Test'/)
.pipe(
catchError(error => {throw err;})
);
}
this returns the following data
{"id":1,"testFields":[{"name":"test_id","value":"12345"},{"name":"testCategory", "value":"testAngular"}, {"name":"testUndefined", "value":""}]}
My TestEntry is
export interface TestEntry{
id:string
testFields:TestFields
}
My TestFields is
export interface TestFields{
name:string
value:string
}