0
Hello,
I’m having trouble recovering the value of an Object in the Firebase Database.
I have the following object on the base:
I wanted to recover in case the value of lastId(108) for later, when saving to the Objects list Words have the last id +1. (This information will be used as a database quence, because the list of Words will serve to feed an Android app)
I made the code below:
var words = firebase.database().ref('Words/');
const list = $firebaseArray(words);
$scope.addWord = function (word) {
var id;
var wdRef = firebase.database().ref('WordsDetail');
wdRef.on('value', function(snap) {
id = snap.val().lastId;
});
words.push({
//idWord: list.length + 1,
idWord: id,//quero usar o id que recuperei aqui!
word: word.word,
description: word.description
});
delete $scope.word;
$scope.wordForm.$setPristine();
}
But the variable id does not take the value.
Would anyone know how to do that?