我试图创建一个用户并使用firebase / angularfire注册他,我想我跟随angularfire文档,但我有" createUserWithEmailAndPassword失败:第一个参数"电子邮件&# 34;必须是有效的字符串。"消息。
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");
});
};
}
]);