I came across the following Stackblitz demo :
https://stackblitz.com/edit/angular-dffny7?file=app
with reference to the below post: https://stackoverflow.com/a/48527939/7429196
Now suppose I have the following JSON
{
"companies": [
{
"company": "ABC",
"projects": [
{
"projectName": "DEF"
},
{
"projectName": "GHI"
}
]
},
{
"company": "JKL",
"projects": [
{
"projectName": "MNO"
}
]
}
]
}
coming from following service:
getCompanies() : Observable<Organization>{
return this.http.get(url).map((response: Response)=> response.json())}
and the Organization class is as following :
export class Organization{
public company: String;
public projects : Project[];
}
export class Project{
public projectName : String;
}
I have the above JSON data in the object of Organization class in my component file and I want to render this data in the form fields in the html file. I tried binding the data using ngModel but read it somewhere that ngModel cannot be used in a model-driven form. How can I achieve it?