今天另一个奇怪的。我在angularjs中创建了一个注册表单,该表单位于一个名为register.html的视图文件夹中。它将在主页中检索并显示ng-view。
控制器也设置在一个单独的文件中,其中包含各种其他控制器。对我来说最大的问题是我无法创建一个寄存器功能,因为角火不断抛出我的错误:
$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
表单还指定了它们的数据类型:
<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">
我真的不明白这个错误意味着什么,并且无法想出更多指定电子邮件和密码的方法。有人可以帮忙吗?