Remove Child Firebase

0

Hello, I'm starting to study Firebase and I'm putting together a simple timeline, but I crashed at the time of trying to delete a certain post. I've seen people saying it's done by remove() , but I do not know how to apply it to the code. Thanks in advance for your help. link

    
asked by anonymous 26.06.2018 / 17:17

1 answer

0

In your delete, you call ref.remove() , but ref has never been declared ...

To remove a child, you need to indicate what your key is. I suggest you create a function that will get the key to be removed and then remove it:

function deletePost(postKey){
    feed.child(postKey).remove();
}

And in your onChildAdded you pass the key by parameter to this function:

    '<a class="pull-right feed-menu" id="deletePost" onclick="deletePost('+snapshot.key+')">'+
    
26.06.2018 / 19:54