0

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?

1 Answer 1

1

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"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.