我正在使用带有angularjs的firebase。我想推迟FirebaseAuthClient
回调。一切正常,但如果添加,只是拒绝不起作用。请查看我的代码段。
在工厂
auth.callback = function(error, user) {
$timeout(function() {
if (user) {
deferred.resolve(user);
} else if (error) {
deferred.reject(error);
} else {
//QUESTION HERE, if this line is added, the promise
//will not working at all means function inside
//.then() will not trigger. If I comment it out
//Everything work fine, but how can I know if use logout ?
deferred.reject();
}
}, 0);
return deferred.promise;
}
auth.firebaseAuthClient = new FirebaseAuthClient(firebaseRef, function(error, user) {
auth.callback(error, user);
});
在 .run()
firebaseAuth.callback().then(function(success){
$rootScope.isLoggedIn = true;
}, function(fail) {
$rootScope.isLoggedIn = false;
})