如何使用AngularFire调用Firebase JS方法
How to call Firebase JS method using AngularFire
我正在使用AngularFire(Firebase和AngularJS之间的接口库)。
我想在我的angular代码中调用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.contrller内部(即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);
});
}
相关文章:
- 当用户点击动态创建的链接时,如何调用JS方法.JQuery,ASP.NET MVC
- JS方法显示了未定义的简单示例
- 如何从方法内部获取js方法名称
- 如何在Spotify应用程序中创建discincts JS方法
- 正在寻找特定的JS方法来确认单选按钮的选择
- jquery在上下文中调用JS方法
- js方法链尾
- JS方法绑定与2个不同的这个
- Wy js 方法 toFixed() 返回 NaN
- 从链接调用 js 方法
- 正确的方法是什么,使用THREE.js方法来计算相机的偏航
- 为什么 findRandom() mongoose for node.js 方法不起作用
- Node.js 方法不返回任何响应,挂起请求
- 缺点和替代方案 - JS方法链接
- Rhino API-使用org.mozilla.javascript.Context访问js方法
- jQuery/JS方法链接
- 通过ajax调用从js方法返回值到REST服务
- 在JS方法asp.net C#中获取变量的内容
- 从复杂对象中提取选定数组和属性的JS方法/lib
- UIWebView elementFromPoint js方法return'错误'要素