How to set and get checkbox status in localStorage?


#1

Hi

How I can set and get checkbox status in localStorage?


#2

Anyone there to reply?


#3

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);
}