I’d like to store my checked radio button in local storage from returning data from Ionic 4 Modal . when l click on any radio button to change value and reload page l got same value not saving in local storage
export class Tab1Page {
weather:any;
cities = 'Muscat'
constructor(private https: HttpClient,public popoverController: PopoverController
,public nav : NavController,public modalController: ModalController,
private storage: Storage ) {
this.test()
}
async test (){
this.https.get('weather/'+this.cities+'.json')
.subscribe(data => {
this.weather = data
})
this.storage.set('cities',this.cities)
this.storage.get('cities',this.cities).then((val) => {
console.log('Your city is', val);
});
}
async openUserModal() {
const modal = await this.modalController.create({
component: PopoverstationsPage,
});
await modal.present();
modal.onDidDismiss().then((r) => {
console.log("the result:", r , 'test'+ this.cities);
this.cities = r.data.result
this.test()
this.storage.set('cities',this.cities)
this.storage.get('cities',this.cities).then((val) => {
console.log('Your city is', val);
});
});
}
l puted storage in two function to check if he is saving or not but he doesn’t save . how can l save and keep it value when l change it from radio button even if reload page ?