I have this small app with Firebase and i\'m implementing CRUD operations. The issue comes when I have to delete a post. I get this error: Error: Reference.child failed: F
@Frank van Puffelen snapshotChances() was the solution. This methods returns the id from the node to delete in firebase. So, in the service, I get the reviews like this:
getReviews() {
return this.db.list('/reviews').snapshotChanges();
}
And the HTML should be
<button (click)="delete(r.key)" class="btn btn-danger">Delete</button>
And back in the service, the delete method:
deleteReview(id: any) {
console.log(id)
this.db.object('reviews/' + id).remove();
}
You seem to be changing the meaning of p
from post
to an id
. Assuming that each post
has an id
property, you probably want:
delete(post) {
this.postService.deletePost(post.id)
}