I am working with a Model-class that looks like this:
export class Drivefunction{
public Injection: Injection;
public df_uid_machine_injsiz:string;
public Motor_Cable_IEC: Motor_cable;
...
In my display.component.ts file, I have a function called fillDrivefunctions() that populates an array of Drivefunctions.
fillDrivefunctions(){
this.machineService.getDrivefunctions(this.injectionID)
.subscribe((df:Drivefunction[])=> {
this.drivefunctions = df;
console.log(this.drivefunctions)
});
}
I use console.log to check if the JSON objects are properly filled.
https://i.sstatic.net/nffdV.jpg
All objects and nested objects are filled correctly!
In my HTML file, I iterate over the drivefunction[] array using ngFor. While I can access string properties without any issue, attempting to access a nested object results in an error message "cannot read property of undefined", even though it is filled correctly.
Do I need to subscribe separately to these nested objects?
This is how it looks in my HTML:
<ion-list *ngFor="let drivefunction of this.drivefunctions; ">
<ion-item>
<ion-label>{{drivefunction.Injection.inj_uid_machine_injsiz}}</ion-label>
</ion-item>
</ion-list>