I am currently working on populating a select element in Angular with data. I found an example online that I'm using, but I am unable to see anything rendered on the HTML page. The plan is for the data to eventually come from a service, but for now, I am testing it with hardcoded data. Initially, the example used ngModel, which was causing errors. I attempted to switch it to formGroup, but I'm unsure what should be included inside.
areas: Area = {
id: 1,
nombre: "Contabilidad"
};
onSelect(id: any): void{
console.log('id ', id);
}
<form class="theForm" (ngSubmit)="onSubmit()" [formGroup]="myForm">
<br><br>
<label >Area </label><br>
<select [formGroup]="myForm." (change)="onSelect($event.target.value)">
<option *ngFor="let area of areas" value={{areas.id}}>
{{areas.nombre}}
</option>
</select>
<br><br>
errors:
Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays.
this.form._updateTreeValidity is not a function
The data fetched from the service will consist of collections of IDs and names