有一天,一只虫子跟在另一只虫子后面.关于使用firebase作为我的应用程序的一个简单的数据源的问题已经谈够了。我正要开始实现$firebaseSimpleLogin
时,它崩溃了,我发现虽然堆栈溢出,但它被弃用于$firebaseAuth
。但是,现在我无法更新控制器中的函数,因为它一次又一次地抛出相同的错误:
TypeError:参考文献$authWithPassword不是一个函数
我已经将所有的依赖项添加到我的控制器中,从我的firebase源创建了ref对象,但是它仍然不允许我的用户(已经创建)记录我。
controllersModule.controller('HomeCtrl', ["$scope", "$firebaseAuth",
function($scope, $firebaseAuth) {
var ref = new Firebase("https://<MYUSERAPI>.firebaseio.com");
var auth = $firebaseAuth(ref);
$scope.user = {};
$scope.SignIn = function(e){
e.preventDefault();
var username = $scope.user.email;
var password = $scope.user.password;
$登录(‘密码’,{电子邮件:用户名,密码}) .then(函数(用户){//成功回调console.log(‘身份验证成功’);},函数(错误){ //Failure回调console.log(“身份验证失败”;});}];
它告诉我at ref.$authWithPassword不是一个函数?我是不是漏掉了一个插件?
我有以下版本的火基和角火:
<script src="https://cdn.firebase.com/js/client/2.2.4/firebase.js"></script>
<script src="https://cdn.firebase.com/libs/angularfire/1.1.3/angularfire.min.js"></script>
我已经进入这个页面,https://www.firebase.com/docs/web/guide/login/password.html
,但不能用我的登录/密码版本重新创建他们的选项。
任何帮助都是非常感谢的,尤其是今天。谢谢。
发布于 2015-10-01 19:14:33
我已经修正了回到$authWithPassword和添加auth,就像Anid的文章一样,它是有效的。
$scope.user = {};
$scope.SignIn = function(e){
e.preventDefault();
var username = $scope.user.email;
var password = $scope.user.password;
auth.$authWithPassword ({
email: username,
password: password
})
.then(function(user) {
//Success callback
console.log('Authentication successful');
}, function(error) {
//Failure callback
console.log('Authentication failure');
});
}
发布于 2015-10-01 18:40:09
$authWithPassword
是AngularFire方法,而不是Firebase引用方法。应该在auth
变量上调用该方法。
https://stackoverflow.com/questions/32894504
复制相似问题