Reputation: 465
I would like to delete the item2 if i choose the delete button of item2.
{
"items" : {
"category1" : {
"item" : {
"0" : {
"name" : "item1",
},
"1" : {
"name" : "item2",
},
"2" : {
"name" : "item3",
}
}
},
"category2" : {
"item" : {
"0" : {
"name" : "item1",
}
}
}
}
I tried with this code:
removeItem: function (item, category) {
db.ref('items').child(category1).child('item').child(item['.key']).remove()
},
Anybody see what i missing?
Upvotes: 0
Views: 69
Reputation: 10624
Try doing something like this:
removeItem: function (category, itemId) {
db.ref('items').child(category).child('item').child(itemId).remove()
}
Considering: category
is "category1"
and itemId
is "1"
.
So, the function will be called as: removeItem("category1", "1")
// to delete "item2"
Upvotes: 1