How to save a state for checkbox in Popover?



I’ve a checkbox in Popover. Once it is checked and I close the checkbox and when I open the popover again it is unchecked.

How I can save the checkbox even after restarting my application?

Best Regards


Anyone there to reply?


Post your code snippet


I would imagine a boolean, an array of values, and the storage module of your choosing could combine to make that happen


I want the checkbox checked even after popover is closed. Currently checkbox gets unchecked when I close the popover.

Here is the code:


<ion-list class="popover-items">
    <ion-checkbox (click)="activateEnglish()"></ion-checkbox>




In ion-checkbox, put checked=“value”

In popover.ts,

value: boolean=false

value= true


I tried this but it is not working.


Please anyone else have the solution?


you should store it in localstorage


How can I save checkbox state in localStorage? I tried to find similar solution but I couldn’t get it.


Myself I achieve this in this way: (By using global variables, this is not the correct way, but I couldn’t think of an other way)

I create an configProvider

import { Injectable } from '@angular/core';
import { Storage} from "@ionic/storage";

export class ConfigProvider {

    public englishActivated: boolean;

	constructor(private storage: Storage) {

loadConfigData(){ => {'englishActivated').then((val) => {
		  this.englishActivated = val;

import configprovider and add ngbind popover.ts

//import configProvider
<ion-list class="popover-items">
    <ion-checkbox  [(ngModel)]="configProvider.englishActivated" (click)="activateEnglish()"></ion-checkbox>

and inside of your activateEnglish function you should also make sure the new state is being saved to storage

    this.textEle.classList.toggle('showEnglish'); =>
  'activateEnglish',boolean true / boolean false)


Hey man!

I tried this solution many times but I get an error that

Runtime error Cannot read property of "englishActivated".


I now see I set the value activateEnglish but I get englishActivated, make the setted and the getted value the same, whichever you like, and you error should be gone.