why does the code return and not the value
$scope.profileThenEdit = { userEdit: function () { ref.child('users').child(ref.getAuth().uid).child('mailregister').once("value", function (snapshot) { return snapshot.child("edit").val() }); } }; $scope.$watch('profileThenEdit.userEdit', function (dataLoaded) { console.log(dataLoaded); //if (dataLoaded) { // $location.path('profile'); //} else { // $location.path('editprofile'); //} });