Hello,
I am using Ionic v.6.7.0 and tried to create a two page android application. When I connect a variable (“car_id”) by ngModel to my radio-group, navigate to another page, change the variable and return to the first page, no radio-button is selected. The variable is changed correctly (proofed by printing it out). If I reset the variable by e.g. , the correct radio-button becomes selected.
home.page.html
<ion-radio-group (ionChange)="carChangeEvent($event)" [(ngModel)]="car_id">
<ion-item>
<ion-label>Button 1</ion-label>
<ion-radio slot="start" value="1"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Button 2</ion-label>
<ion-radio slot="start" value="2"></ion-radio>
</ion-item>
<ion-item>
<ion-label>Button 3</ion-label>
<ion-radio slot="start" value="3"></ion-radio>
</ion-item>
</ion-radio-group>
home.page.ts
export class HomePage {
public car_id: string = "1";
...
constructor(...) {...}
carChangeEvent (event) {
switch(this.car_id) {
case "1": {
...do stuff by car_id...
break;
}
case "2": {
...do stuff by car_id...
break;
}
case "3": {
...do stuff by car_id...
break;
}
default: {
this.msg2 = "switch default";
console.log('ERROR: Invalid car identifier: ' + event.target.value);
break;
}
}
}
Is it a bug of ion-radio/ion-radio-group or am I doing a mistake?
1 post - 1 participant