Cannot get RadioButton component object from ionSelect ion-radion


#1

I cannot get the $event of ionSelect function of ion-radio tag as a RadioButton component
here is my code:

                <ion-list radio-group>
                    <ion-item class="item-child">
                        <ion-label>Manual</ion-label>
                        <ion-radio item-start (ionSelect)="changeMode($event)" [checked]="actuator.mode === actuatorMode.MANUAL" color="secondary"></ion-radio>
                    </ion-item>
                    <ion-item class="item-child">
                        <ion-label>Auto</ion-label>
                        <ion-radio item-start (ionSelect)="changeMode($event)" [checked]="actuator.mode === actuatorMode.AUTO" color="secondary"></ion-radio>
                    </ion-item>
                </ion-list>

ts file:

    public changeMode(event: RadioButton) {
        console.log(event);
}

it logs like this rb-11-0
What is the problem ?


#2

I don’t know why you’re making this so complicated.

  <ion-list radio-group [(ngModel)]="actuator.mode" (ionChange)="onActuatorChange()">
    <ion-item class="item-child">
      <ion-label>Manual</ion-label>
      <ion-radio item-start value="manual" color="secondary"></ion-radio>
    </ion-item>
    <ion-item class="item-child">
      <ion-label>Auto</ion-label>
      <ion-radio item-start value="auto" color="secondary"></ion-radio>
    </ion-item>
  </ion-list>

Inside onActuatorChange() you can peek into actuator.mode to see the newly activated setting.


#3

because I don’t want to make the radio button selected if the changeMode function does not do as I want. follow here How do I prevent an ion-checkbox from being checked?, I think I have to get the RadioButton object and set checked to false if changeMode function does not work as expected.