$authWithPassword 不是 AngularFire 2.x 中的函数

2023-12-26

我以前看过有关此问题的帖子,但它们要么已经过时,要么提供与我的设置非常相似的解决方案。

基本上,我的控制器中有两个函数:authCtrl.login 和 authCtrl.register。寄存器对 Auth.$createUserWithEmailAndPassword() 的调用工作正常,但登录对 Auth.$authWithPassword() 的调用则不然,因为我收到“..不是函数”错误。我一生都无法弄清楚这里出了什么问题。

这是我的设置:

auth.service.js:

angular.module('angularfireSlackApp')
.factory('Auth', function($firebaseAuth, $firebaseObject){
var auth = $firebaseAuth();

return auth;
});

auth.controller.js:

angular.module('angularfireSlackApp')
.controller('AuthCtrl', function(Auth, $state){
var authCtrl = this;

authCtrl.user = {
  email: '',
  password: ''
};

authCtrl.login = function() {
// Why is this not a function
Auth.$authWithPassword(authCtrl.user)
.then(function (auth){
  $state.go('home');
}, function (error){
  authCtrl.error = error;
});
}

authCtrl.register = function() {
Auth.$createUserWithEmailAndPassword(authCtrl.user.email, authCtrl.user.password)
.then(function (user){
  authCtrl.login();
}, function (error){
  authCtrl.error = error;
});
}

});

try $signInWithEmailAndPassword

请参阅文档:https://github.com/firebase/angularfire/blob/master/docs/reference.md#signinwithemailandpasswordemail-password https://github.com/firebase/angularfire/blob/master/docs/reference.md#signinwithemailandpasswordemail-password

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

$authWithPassword 不是 AngularFire 2.x 中的函数 的相关文章

随机推荐