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

Ionic Storage / Toggle

$
0
0

I have a very simple question , i am building an app where i have a settings page with a toggle input for a user to turn on and off some alerts . My question is how do i save the toggle value so as when someone closes the app or navigate to another page the toggle status should not get lost and the current toggle should be reflected in html.

Page.html:

<ion-toggle [(ngModel)]="toggleStatus" (ionChange)="Button1();"></ion-toggle>

Ts:

export class Tab1Page {

  toggleStatus: any;

  

  constructor(public alert: AlertController, public navCtrl: NavController, public storage: Storage) {
    storage.ready().then(() => {
      storage.get('toggleStatus').then((val) => {
        console.log(`Setting status from storage to '${this.toggleStatus}'`);
        this.toggleStatus = val;
      })
    });
  }

  Button1() {
    console.log(`changing toggleStatus to '${this.toggleStatus}'`);
    this.storage.set('toggleStatus', this.toggleStatus);
  }

Get this error:
Property ‘ready’ does not exist on type 'Storage’

Can someone help me?

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 48981

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>