我创建了一个用户登录模板。我想用firebase注册用户。
我收到以下错误。
错误:Firebase.createUser失败:第一个参数必须包含密钥" email"类型"字符串" 在错误(本机)
我的控制器
.controller('LoginCtrl', ['$firebaseAuth','$scope','$timeout','$stateParams',function($firebaseAuth,$scope, $timeout, $stateParams) {
console.log("Login Control");
$scope.signupEmail = function() {
var ref = new Firebase("https://requestmaker.firebaseio.com");
ref.createUser({
email: $scope.email,
password: $scope.password
}, function(error, userData) {
if (error) {
console.log("Error creating user:", error);
} else {
console.log("Successfully created user account with uid:", userData.uid);
}
});
};
}]);
..在我的index.html文件中,我已经包含了
<!-- firebase.js -->
<script src="https://cdn.firebase.com/js/client/2.3.2/firebase.js"></script>
<!-- AngularFire -->
<script src="https://cdn.firebase.com/libs/angularfire/1.1.2/angularfire.min.js"></script>
..在我的离子视图模板中
<button class="button button-full button-assertive" ng-click="signupEmail()">Login</button>
请告诉我哪里错了。
.controller(&#39; SignInCtrl&#39;,功能($ scope,$ rootScope,$ state,$ ionicHistory,Auth,UserData,$ firebase){
$scope.hideBackButton = true;
/* FOR DEV PURPOSES */
$scope.user = {
email: "",
password: ""
};
$scope.signIn = function (user) {
$rootScope.show('Logging In...');
/* Check user fields*/
if(!user.email || !user.password){
$rootScope.hide();
$rootScope.notify('Error','Email or Password is incorrect!');
return;
}
/* All good, let's authentify */
Auth.$authWithPassword({
email : user.email,
password : user.password
}).then(function (authData) {
console.log(authData);
$rootScope.hide();
}).catch(function (error) {
$rootScope.hide();
$rootScope.notify('Error','Email or Password is incorrect!');
});
};
谢谢, Sabarisri
答案 0 :(得分:0)
.controller('SignInCtrl',函数($ scope,$ rootScope,$ state,$ ionicHistory,Auth,UserData,$ firebase){
$scope.hideBackButton = true;
/* FOR DEV PURPOSES */
$scope.user = {
email: "",
password: ""
};
$scope.signIn = function (user) {
$rootScope.show('Logging In...');
/* Check user fields*/
if(!user.email || !user.password){
$rootScope.hide();
$rootScope.notify('Error','Email or Password is incorrect!');
return;
}
/* All good, let's authentify */
Auth.$authWithPassword({
email : user.email,
password : user.password
}).then(function (authData) {
console.log(authData);
$rootScope.hide();
}).catch(function (error) {
$rootScope.hide();
$rootScope.notify('Error','Email or Password is incorrect!');
});
};