Beta 3, ion-radio checked not working anymore [SOLVED]


#1

Hi,

Am I the only one that has issue with beta 3 and ion-radio checked properties?

Even hardcoded value does not put any check mark


#2

Ok, forget it. It seems the way to do it is using the ngModel.

sorry about that


#3

@icarus_31 can you provide sample code on how you achieved this? I’m having the same issue and haven’t been able to figure it out yet.

I am able to save the selected ion-radio item to the DB just fine and go back to the parent page. But when I navigate back to the child page I want to show the “checked” option.


#4

Hi @gigocabrera,

What I did is nothing fancy:

HTML

  <ion-list radio-group [(ngModel)]="myModel">
    <ion-item>
      <ion-label>Value1</ion-label>
      <ion-radio value="valueA"></ion-radio>      
    </ion-item>

    <ion-item>
      <ion-label>Value2</ion-label>
      <ion-radio value="valueB"></ion-radio>
    </ion-item>

    <ion-item>
      <ion-label>Value3</ion-label>
      <ion-radio value="valueC"></ion-radio>
    </ion-item>
  </ion-list>

TS

onPageWillEnter() {
   // in my case, I get the previously saved selection from the local storage
   myModel = value from localstorage
}

Hope that help


#5

@icarus_31 you’re awesome man :+1: Thank you very much for your help :pray:
I’ve been pulling my hair for 2 days now trying to get this to work. What I was missing was this part
myModel = value from localstorage