0

I'm trying to write to an object in firebase, here is how i did it:

var myDataRef = new Firebase('https://ootest1.firebaseio.com/users/' + '-J6kDooooooz_eV3Cq' /*JobsManager.getCurrentUser().username*/);
angularFire(myDataRef, $scope, 'newUser');

if (!$scope.newUser.jobs)
    $scope.newUser.jobs = [];

The problem is that $scope.newUser is undefined.
Why is that?

1 Answer 1

1

The angularFire binding returns a promise, and the $scope.newUser model won't be defined until that promise is fulfilled:

var promise = angularFire(myDataRef, $scope, 'newUser');
// $scope.newUser is undefined
promise.then(function(){
  // $scope.newUser is defined
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.