Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 48980

How to keep the radio button checked after app reload

$
0
0

I have a function that I call after clicking on a radio button. This function sets the location preference then reloads the app. ( the app has to reload as it brings up the secondary app depending on the location preference )

when reloading I have a get function in NgOnInit to get the location preference, with this i try to set the radio button checked value but app keeps breaking as “checked” is not a property of radio

 getLocationPreference(){
    if (this.preference === "US"){
      this.US = true;
      this.International = false
    } else {
      this.US = false;
      this.International = true
    }
  }

this is the HTML:

<ion-grid>
        <ion-radio-group>
        <ion-row>
          <ion-col size="6">
            <ion-item color="secondary" (click)="saveLocationPreference('US')">
              <ion-label>US</ion-label>
              <ion-radio value="US"></ion-radio>
            </ion-item>  
          </ion-col>
          <ion-col size="6">
            <ion-item color="secondary" (click)="saveLocationPreference('International')">
              <ion-label>International</ion-label>
              <ion-radio value="International"></ion-radio>
            </ion-item>
          </ion-col>
        </ion-row>
      </ion-radio-group>
      </ion-grid>

how do I i keep the radio button checked after app reload? because when the app reloads both radio buttons are empty

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 48980

Trending Articles