1

我正在使用AngularFireFirebase和AngularJS之间的接口库)。如何使用AngularFire调用Firebase JS方法

我想在我的角码中调用javascript方法sendEmailVerification()。当我执行下面的代码,我得到一个错误说:$scope.authObj.sendEmailVerification is not a function.这可能是因为我想在AngularJS(AngularFire)中使用javascript方法。

有没有一种方法可以通过使用AngularFire来使用Javascript方法?

$scope.signUp = function() { 

    $scope.authObj.$createUserWithEmailAndPassword($scope.email, $scope.password) 
    .then(function(firebaseUser) { 

     $scope.sendVerifyEmail(); 

    }).catch(function(error) { 
     console.error("Error: ", error); 
    }); 
} 

$scope.sendVerifyEmail = function(){ 
    $scope.authObj.sendEmailVerification(); 
} 

回答

2

我想通了,我可以写一个JavaScript函数外app.controller所要求的火力地堡方法和app.controller即内部称之为角方法里面。

下面是我更新的代码

// The below JS function written outside app.controller 
function sendVerifyEmail(firebaseUser){ 
    firebaseUser.sendEmailVerification(); 
} 

上面JS函数是从以下角度函数调用

$scope.signUp = function() { 

    $scope.authObj.$createUserWithEmailAndPassword($scope.email, $scope.password) 
    .then(function(firebaseUser) { 

     sendVerifyEmail(firebaseUser); 

    }).catch(function(error) { 
     console.error("Error: ", error); 
    }); 
} 
相关问题