How to store checkbox values in Firestore

Hello, I’m trying to change firestore values checking boxes on Ionic 5, but don’t know how to deal with it, i need help, thank you.

That’s my code :slight_smile:

//TS

isSubscribed($event, id) {
console.log("Value checkbox: ", $event.target.value, id)
this.db.collection(‘users’).doc(id).set({
subscribed: $event.target.value
})
}

//HTML

{{ subscriber.fullname }} Subscribed

You can do this. Follow this simple example:

HTML

<!-- Checkboxes in a List -->
<ion-list>
  <ion-item *ngFor="let entry of form">
    <ion-label>{{entry.val}}</ion-label>
    <ion-checkbox slot="end" [(ngModel)]="entry.isChecked" (ionChange)="triggerEvent($event, entry.val)"></ion-checkbox>
  </ion-item>
</ion-list>

Typescript

public form = [
  { val: 'Pepperoni', isChecked: true },
  { val: 'Sausage', isChecked: false },
  { val: 'Mushroom', isChecked: false }
];

triggerEvent(event, value) {
  this.db.collection('users').doc(id).set({
    value: event.detail.checked
  })
}

Hope it helps!

At the end only I “update” the “doc” and is working perfectly and fast :slight_smile: didn’t know about event.detail.checked jeje