@DeegC wrote:
I’m using radio buttons on a form. Everything is fine when changing the value via the user interface. However, if I change the ngModel value in code the radio group gets de-selected and then the ngModel value (eventually) gets changed to undefined. What am I doing wrong?
HTML:
<ion-radio-group (click)="doTextSearch()" [(ngModel)]="showOnlyRated"> <ion-row> <ion-col> <ion-item> <ion-label>All</ion-label> <ion-radio mode="md" value="1"></ion-radio> </ion-item> </ion-col> <ion-col> <ion-item> <ion-label>Rated</ion-label> <ion-radio mode="md" value="2" [disabled]="! userService.isUserLoggedIn"></ion-radio> </ion-item> </ion-col> <ion-col> <ion-item> <ion-label>Rated by Me</ion-label> <ion-radio mode="md" value="3" [disabled]="! userService.isUserLoggedIn"></ion-radio> </ion-item> </ion-col> </ion-row> </ion-radio-group>Code where I change the value is simply:
this.showOnlyRated = 3;What can I do to make this work?
Versions:
@ionic/angular: 4.11.4
@angular/common: 8.2.13
Posts: 2
Participants: 2