我正在使用AngularFire(Firebase和AngularJS之间的接口库)。
我想在我的角度代码中调用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();
}
最佳答案
我只是想知道我可以使用所需的Firebase方法在app.controller外部编写一个javascript函数,然后从app.controller内部即Angular方法内部进行调用。
下面是我更新的代码
// 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);
});
}
关于javascript - 如何使用AngularFire调用Firebase JS方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/38669930/