Trying to determine the existence of a child, I have created a new Firebase list observable and also attempted with an object observable. Upon creating the observable, I verify if it exists or not; however, it always returns false.
Database Structure:
{Rooms:[
{0:
{name:ok}
},
{1:
{name:second}
}
]}
Angular2 code:
isRoom(num){
let isRoom: boolean;
var Exists:FirebaseListObservable<any[]>;
Exists=AngularFire.database.list('/Rooms/'+num);
Exists.subscribe(snapshot =>{
if(snapshot.exists()){
console.log("Exists");
isRoom=true;
}else{
console.log("Doesn't exist");
isRoom=false;
}
return isRoom;
});