I've got many examples of this. Using FormGroup, Ion Select, the value is always set properly, but nothing shows until I manually open the select and close it. This behavior makes the Reactive Form totally useless for editing or updating, which effectively means it is useless. I don't have any form that doesn't need a select, and while it does work ok for inserting new values, it means I have built one form for inserting and another totally different form for updates.
I'll paste some code in here, but I'm sure everyone using Ionic 3 has seen the problem. When will it be fixed, and is there a workaround?
<ion-content>
<div *ngIf="loginForm">
<form [formGroup]="loginForm" (submit)="doLogin()">
<ion-list>
<ion-item *ngIf="lookupsProvider">
<ion-label fixed>{{ 'PHONE_COUNTRY_CODE' | translate }}</ion-label>
<ion-select type="input" name="country_id" formControlName="country_id">
<ion-option *ngFor="let country of lookupsProvider.lookupData['countrys']"
value="{{ country['id'] }}">
<ion-item>
{{ this.optionText(country) }}
</ion-item>
</ion-option>
</ion-select>
</ion-item>
.... other inputs of course
and in the .ts file
_buildForm() {
this.loginForm = this.formBuilder.group({
country_id: [this.settingsProvider.settings['USER_ID'], Validators.required],
main_phone: ['', Validators.required],
password: ['', Validators.required]
});
this.loginForm.valueChanges.subscribe((v) => {
console.log('Login loginForm.valueChanges: ' + v);
});
}
As I mentioned, the values are set correctly, but all the user sees is a blank select... This is the login form, but we know the user's country, so we'd like them not to have to choose it. Because the value doesn't show, the user ends up having to select it to be sure it's set.