I'm working with firestore, where i've written a service code to delete the document from one of the collection.
Service Code:
firestore.service.ts
deleteFromCollection(id: string){
this.eventDoc = this.afs.doc(`bookings/${id}`);
return this.eventDoc.delete();
}
Main Code:
blank.component.ts
deleteData(){
let audio = new Audio();
audio.src= "./assets/app/media/sound/to-the-point.mp3";
audio.load();
this._firestoreService.deleteFromCollection(this.eventToShow.id).
then(function(){
this.closeEditModal();
audio.play();
this.showToastr("Deletion Done Successfully");
}).
catch(function(error){
this.closeEditModal();
audio.play();
this.showToastr("Deletion Error");
});
}
showToastr(msg){
this.message = true;
this.deletionMessage = msg;
setTimeout(() => this.message = false, 5000);
}
closeEditModal(){
$('#edit_modal').removeClass('show');
}
So when i'm using the above code the deletion is performed, but then section is not able to call showToastr/closeEditModal method which already present in BlankComponent Class.
It's giving this error:
TypeError: Cannot read property 'closeEditModal' of undefined.
and same error for showToastr method.
Please Help