0

今天又一个奇怪的。我正在 angularjs 中创建一个注册表单,该表单位于一个名为 register.html 的视图文件夹中。它被检索并显示在主页中的 ng-view 中。

控制器也与其他各种控制器一起设置在单独的文件中。对我来说最大的问题是我无法创建注册函数,因为 angular fire 不断抛出我的这个错误:

 $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">

我真的不明白这个错误是什么意思,也想不出更多指定电子邮件和密码的方法。有人可以帮忙吗?

4

0 回答 0