I have couple of values coming from DB, and I want to set one of the value as default value for the drop-down form element, tried many way but couldn't fix the issue
my.ts:
phoneTypes;
defaultValue;
ngOnInit() {
this.getPhoneTypes();
}
getPhoneTypes() {
this.myService.getPhoneTypes().subscribe(data=>{
this.phoneTypes= data;
});
}
defaultValue = this.phoneTypes.name;
initForm() {
phoneType : new FormControl()
}
my.html
<div id = "someId">
<select formControlName="phoneType" [(ngModel)]="defaultValue">
<option *ngFor="let phoneType of phoneTypes" [value]="phoneType.code" >{{phoneType.name}}</option>
</select>
</div>
but I see value is binding by default, I don't see the default value is coming.