My goal is to dynamically load select options based on an API response, using observables in Angular 5 for HTTP requests.
However, when trying to parse the response into select options, I encountered the following error:
Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables such as Arrays
ngOnInit() {
this.roles = this.roleService.getRoles();
console.log("Roles Are here",this.roles);
}
}
html
<select id="userrole" class="form-control " name="userrole" formControlName="userrole" data-live-search="true">
<option *ngFor="let p of roles" value={{p[0]}}>{{p[1]}}</option>
</select>
View the Plunkr demo here