0

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

1 に答える 1

1

関数呼び出しの失敗コールバック内に return $q.reject(reason) コードがありません。

$q angularjs docsでカバーされています

于 2013-06-07T18:24:26.730 に答える