I have created some models and I need to use the type that will be assigned as an array. After receiving a result from an api call, I instantiate a new object of my 'type', but the result is an array. How can I make this work?
When I set the variable parents = new Parents()
and then try to use it in Angular with an ngFor
, it raises an error about only allowing the use of arrays...
However, when I set parents:any
, it works without any issues. I'm still not fully grasping it.
parents = new Parent();
Then, after the API returns with the data:
this.parents = this.user.parents;
which is in array form
export class Parent {
id: number;
email: string;
title: string;
first_name: string;
last_name: string;
profile_image: string;
}