Reputation: 1174
In my ionic (angular) app,
Currently, firebase.auth().currentUser
returns as null.
$ionicPlatform.ready(function(){
firebase.auth().currentUser --> null
});
But
.controller('MyController', function($scope, $ionicPopup, $firebaseAuth) {
$scope.$on('$ionicView.afterEnter', function(e) {
firebase.auth().currentUser --> is valid
});
});
Upvotes: 3
Views: 1178
Reputation: 2646
You can simply use $loaded
function which returns a promise which is resolved when the initial server data has been downloaded.
var ref = new Firebase("https://<YOUR_FIREBASE_APP>.firebaseio.com/foo");
var obj = new $firebaseObject(ref);
obj.$loaded().then(function() {
console.log(obj.$value); // "bar"
});
more info: https://www.firebase.com/docs/web/libraries/angular/guide/synchronized-objects.html
Upvotes: 1