I wrote a function to check if there is a data saved in "phonenumber" child on my firebase database or not .. the tests are OKEY! but inside this function I can't call an external declared variable ! this is code:
phoneNumberExistence: boolean;
FIREBASE_DATABASE.ref("Settings").child('phoneNumber').once('value', function(snapshot) {
      var exists = (snapshot.val() !== null);
      //console.log("Phone number existance: "+exists);
      if(exists){
        this.phoneNumberExistence = true; //the problem is here.. can't use this variable
        console.log("A phone number already exists.")
      }
      else{
        this.phoneNumberExistence = false; //the problem is here.. can't use this variable
        console.log("There is no phone number here :(");
      }
    })
Any idea ? thanks
 
     
    