Firebase auth.$createUser认为电子邮件和密码是字符串
今天还有一个奇怪的。我正在angularjs中创建一个注册表单,该表单位于名为register.html的视图文件夹中。它被检索并显示在主页的ng视图中 控制器也与其他各种控制器一起设置在单独的文件中。对我来说,最大的问题是我无法创建寄存器函数,因为angular fire不断抛出我的错误:Firebase auth.$createUser认为电子邮件和密码是字符串,firebase,createuser,Firebase,Createuser,今天还有一个奇怪的。我正在angularjs中创建一个注册表单,该表单位于名为register.html的视图文件夹中。它被检索并显示在主页的ng视图中 控制器也与其他各种控制器一起设置在单独的文件中。对我来说,最大的问题是我无法创建寄存器函数,因为angular fire不断抛出我的错误: $createUser() expects an object containing 'email' and 'password', but got a string. 这很疯狂,因为在我的函数中,两个
$createUser() expects an object containing 'email' and 'password', but got a string.
这很疯狂,因为在我的函数中,两个都是变量:
//Register controller
controllersModule.controller("RegCtrl", ["$scope", "$firebaseAuth",
function($scope, $firebaseAuth){
var ref = new Firebase("https://<MY APP>.firebaseio.com");
var auth = $firebaseAuth(ref);
$scope.signUp = function() {
if (!$scope.regForm.$invalid) {
var email = $scope.user.email;
var password = $scope.user.password;
if (email && password) {
auth.$createUser(email, password)
.then(function() {
// do things if success
console.log('User creation success');
}, function(error) {
// do things if failure
console.log(error);
console.log('something is not right');
$scope.regErrorMessage = error.message;
});
}
}
};
}]);
//.End Register controller
//寄存器控制器
controllersModule.controller(“RegCtrl”[“$scope”,“$firebaseAuth”,
函数($scope,$firebaseAuth){
var ref=新的火基(“https://.firebaseio.com");
var auth=$firebaseAuth(ref);
$scope.signUp=函数(){
if(!$scope.regForm.$invalid){
var email=$scope.user.email;
var password=$scope.user.password;
如果(电子邮件和密码){
auth.$createUser(电子邮件、密码)
.然后(函数(){
//如果成功了,就去做
console.log(“用户创建成功”);
},函数(错误){
//如果失败了,就去做
console.log(错误);
log('有点不对劲');
$scope.regErrorMessage=error.message;
});
}
}
};
}]);
//.终端寄存器控制器
该表单还指定了它们所属的数据类型:
<input type="password" name="password" class="form-control" ng-model="user.password" ng-minlength="8">
<input type="email" name="email" class="form-control" ng-model="user.email">
我真的不明白这个错误意味着什么,想不出更多的方法来指定电子邮件和密码。有人能帮忙吗?请看这里的代码示例:您将看到
$firebaseAuth.$createUser()
获取一个具有两个命名属性的对象:email
和password
$firebaseAuth(ref)。$createUser({email:$scope.email,password:$scope.password})
我现在在手机上,但这是否意味着我可以像上面定义的变量那样使用({email:email,password:password})?我现在可以测试它了。成功了!auth.$createUser({email:email,password:password})谢谢!