Here is my code
import {Component} from "@angular/core";
import {ViewController, Events} from "ionic-angular";
import {FormBuilder, Validators} from "@angular/forms";
export class AccountEditModalPage {
form: any;
constructor(private viewCtrl: ViewController,
private ionic: IonicUtilProvider,
private formBuilder: FormBuilder) {
}
ionViewWillLoad() {
// Validate user registration form
this.form = this.formBuilder.group({
gender: ['male', Validators.required],
});
_.each(this._user, (value, key) => {
if (this.form.controls[key]) {
this.form.controls[key].setValue(value);
}
});
}
}
and on my html page
<ion-item>
<ion-label stacked>{{'Gender' | translate}}</ion-label>
<ion-select formControlName="gender">
<ion-option value="male">{{'Male' | translate}}</ion-option>
<ion-option value="female">{{'Female' | translate }}</ion-option>
</ion-select>
</ion-item>
The problem is the ionic select does not select the option although the form control has the correct value. Is it Angular bug or Ionic bug?