How to set and get checkbox status in localStorage?

Hi

How I can set and get checkbox status in localStorage?

Anyone there to reply?

You should utilize Ionic Storage instead of localStorage, unless you only want partial persistence.

But you’d do something like
Template:

<ion-checkbox [(ngModel)]="isChecked" (ionChange)="checkChanged()"></ion-checkbox>

Controller:

public isChecked = false;

constructor(private storage: Storage) {}

public checkChanged() {
  this.storage.set("isChecked", this.isChecked);
}
1 Like