Davide Barbieri Davide Barbieri - 8 months ago 54
AngularJS Question

adding objects to Firebase database

i'm trying to add objects to a Firebase database, and i'm trying to retrieve the name and value from two text boxes.

<label class="item item-input">
<span class="input-label">Beer Name</span>
<input type="text" id='nomeBirra'>
<label class="item item-input">
<span class="input-label">Review</span>
<textarea name="comment" placeholder="Enter review" id="Recensione"></textarea>

this retrieves the two text areas:

var nameBirra=document.getElementById("nomeBirra")
var valueBirra=document.getElementById("Recensione")

this is the piece of code that adds a new object to database

name: nameBirra,
value: valueBirra

the problem is that it works, but the two parametres appear empty in the database, how can i retrieve the values inside the text boxes? or it's some other thing that is wrong?


The firebase syntax is right, which is why it's appearing in the database - it's the other bit that is wrong. There are a few things that could be wrong but it's hard to say without seeing the context (e.g. are those getElementByIds wrapped in a function etc?) but the most obvious one is that you need to get the VALUE of the input box, not the box itself. So, first thing to try:

var nameBirra=document.getElementById("nomeBirra").value