Pregunta

So after getting used to AngularFire these last few days, I stumbled upon the angularFire() constructor.

I am calling it as this at the moment :

angularFire(new Firebase(FBURL + '/users' + $scope.auth.id), $scope, 'user');

If I understand it correctly, the first argument is an url that points to the current logged in user (assuming my login works correctly off course, which it does).

The second argument is the fact that I want to bind it to a scope.

The third argument is the stringified name of this scope, correct?

I got the angularFire constructor from following this tutorial: http://www.thinkster.io/angularjs/eHPCs7s87O/angularjs-tutorial-learn-to-rapidly-build-real-time-web-apps-with-firebase#item-526c8aae0717fcb66f00020f

  $scope.$on('angularFireAuth:login', function() {
        angularFire(new Firebase(FBURL+'/users/'+$scope.auth.id), $scope, 'user');
      });

Now I did this:

console.log($scope.auth.id);
//prints 16, at this location there is a user
console.log($scope.user)
//prints undefined

I am expecting that $scope.user holds my user object, because at the link is indeed my user object. After trying to pass in '{}' as 4th argument to explicitly ask for an object it still fails.

¿Fue útil?

Solución

I'm not familiar with the constructor you're using. You should be using the $firebase function to set up your bindings.

$scope.user = $firebase(new Firebase(FBURL + '/users/' + $scope.auth.id))

Take a look @ https://www.firebase.com/quickstart/angularjs.html for a quick walk through.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top