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;
})