I have created a FormGroup called holidayform and set it up as follows:
holidayform: FormGroup;
this.holidayform = this.fb.group({
title: ['', [Validators.required]],
entryDate: ['',],
})
this.holidayform.patchValue({
title: data.title,
entryDate: data.entryDate,
})
Within my component, I have a dropdown like this :
<form [formGroup]="holidayform">
<select class="form-control"> <option value="Globals" [selected]="holidayform.title=='Globals'">Global</option>
<option value="Locals" [selected]="holidayform.title=='Locals'">Local</option>
</select>
The usage of
[selected]="holidayform.title=='Globals'"
is not functioning as intended. Instead, I want to select the option based on the value patched in the formgroup.
If anyone has a solution, please share. Thanks!