I am currently working on updating a boolean field in a Firestore document from true
to false
or vice versa.
Initially, the functionality seems to be working well when I toggle the button on and off. However, at times it stops functioning correctly and requires me to press the button multiple times.
You can view my StackBlitz example here: https://stackblitz.com/edit/angular-ea3wme
myComponent.html
<mat-slide-toggle #toggle [checked]="domiciliario.estado" (change)="actualizarEstado(domiciliario.id)"></mat-slide-toggle>
myComponent.ts
actualizarEstado(key){
this.fs.updateEstado(key);
}
myService.ts
estadoChange: boolean = !false || !true;
updateEstado(key){
this.afs.doc('domiciliarios/' + key).update({
estado : this.estadoChange = !this.estadoChange
})
}