Hello, everybody, I have have a quite estrange issue when using ion-select fo fill in a FormArray nested inside a FormGroup (wich contains more atributes rather than just the ‘week’ one. I just want a dropdown menu with the days of the week (initializing all days as false).
ngOnInit() {
this.form = new FormGroup({
week: new FormArray([
new FormControl(false),
new FormControl(false),
new FormControl(false),
new FormControl(false),
new FormControl(false),
new FormControl(false),
new FormControl(false),
])
});
}
get week(): FormArray { return this.form.get('week') as FormArray; }
and then on the html:
<form [formGroup]="form">
<ion-row>
<ion-col size="12">
<ion-item>
<ion-label>Days of the week</ion-label>
<ion-select
formArrayName="week"
multiple="true"
cancelText="cancel"
okText="ok">
<ion-select-option
ngDefaultControl
*ngFor="let day of week.controls ; index as i"
[formControlName]=i
> {{ i }} </ion-select-option>
</ion-select>
</ion-item>
</ion-col>
</ion-row>
</form>
I got the next issues:
As you can see, ion-select is not working properly.
Everything works fine if I replace [formControlName] with [value] but then It’s no longer connected to the form that I want to fill.
¿is there any solution? ¿any workaround?
Thank you in advance.