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
//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
fizak
November 3, 2020, 7:29am
2
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!
Manel00
November 4, 2020, 12:51pm
3
At the end only I “update” the “doc” and is working perfectly and fast didn’t know about event.detail.checked jeje