Ошибка createUserWithEmailAndPassword: первый аргумент «email» должен быть допустимой строкой - PullRequest
0 голосов
/ 17 мая 2018

Я пытаюсь создать пользователя и зарегистрировать его с помощью firebase / angularfire, я думаю, что следую документации angularfire, но у меня «createUserWithEmailAndPassword не удалось: первый аргумент« email »должен быть допустимой строкой».сообщение.

    enter code here
<ion-view>
    <ion-content padding="false">
        <div class="list list-inset">
            <label class="item item-input">
              <input type="text" ng-model="email" placeholder="e-mail">
            </label>
            <label class="item item-input">
              <input type="text" ng-model="password" placeholder="Password">
            </label>
          </div>
          <div class="item item-divider text-center">
            <a href="" class="button button-positive button-small" ng-click="createUser()">
                Enregistrez
            </a>
        </div>
    </ion-content>
</ion-view>

    'use strict';

    app
        .factory("Auth", ["$firebaseAuth",
        function($firebaseAuth) {
            console.log("factory");
        return $firebaseAuth();
        console.log("factory");
        }
        ])
        .controller('homepageIndex',function($scope){
        })
        .controller('homepageSignUp', ['$scope', 'Auth', function($scope, Auth) {

                $scope.createUser = function() {

                // Create a new user
                Auth.$createUserWithEmailAndPassword($scope.email, $scope.password)

                  .then(function(firebaseUser) {
                  }).catch(function(error) {
                      console.log("error");
                  });
              };
            }
          ]);

если это может кому-то помочь, я нашел способ, подобный этому, я не знаю, лучший ли это способ:

<ion-view>
    <ion-content padding="false">
        <div class="list list-inset">
            <label class="item item-input">
              <input type="text" ng-model="newUser.email" placeholder="e-mail">
            </label>
            <label class="item item-input">
              <input type="text" ng-model="newUser.password" placeholder="Password">
            </label>
          </div>
          <div class="item item-divider text-center">
            <a href="" class="button button-positive button-small" ng-click="registerUser(newUser)">
                Enregistrez
            </a>
        </div>
    </ion-content>
</ion-view>


'use strict';

app.factory("Auth", ["$firebaseAuth",
    function ($firebaseAuth) {
        return $firebaseAuth();
    }
]);

app.controller('homepageIndex', function ($scope) {
});

app.controller('homepageSignUp', ['$scope', 'Auth', function ($scope, Auth) {
    var newUser = $scope.newUser = { email: "", password: "" };

    $scope.registerUser = function () {
        Auth.$createUserWithEmailAndPassword(newUser.email, newUser.password)
            .then(function (firebaseUser) {
                console.log("yas", firebaseUser);
            }).catch(function (error) {
                console.log("error");
            });
    };
}

]);
...