我正在使用
的最新版本/ SDK开发应用我尝试通过Firebase(电子邮件和密码)在我的应用中授权用户。 我已经在网上搜索了一个解决方案,但我根本没有让它正常工作。
好吧,只要我点击注册按钮(右上角),我就会收到此错误消息
<ion-modal-view>
<div class="bar bar-header firstStart">
<div class="button button-clear button-positive" ng-click="closeModal()">
Schließen
</div>
<h1 class="title modalTitle">Registrieren </h1>
<div class="button button-clear button-positive"
ng-click="signupEmail()"> Speichern </div>
</div>
<ion-content class="has-header" padding="true">
<div class="list list-inset">
<label class="item item-input item-floating-label">
<i class="icon ion-ios-email placeholder-icon"></i>
<span class="input-label">E-Mail</span>
<input type="email" ng-model="data.email" placeholder="E-Mail" id="email">
</label>
<label class="item item-input item-floating-label">
<i class="icon ion-ios-locked placeholder-icon"></i>
<span class="input-label">Passwort</span>
<input type="password" ng-model="data.password"
placeholder="Passwort" id="password">
</label>
</div>
</ion-content>
.controller('modalController', ['$scope', '$ionicModal','$firebase',
function ($scope, $ionicModal,$firebase)
{
$ionicModal.fromTemplateUrl('templates/register.html', {
scope: $scope,
animation: 'slide-in-up',
backdropClickToClose: false,
hardwareBackButtonClose: false,
focusFirstInput: true
}).then(function (modal) {
$scope.modal = modal;
});
$scope.signupEmail = function () {
$scope.data = {};
var email = $scope.data.email;
alert(email);
var password = $scope.data.password;
alert(password);
/*if (email.length < 4) {
alert('Please enter an email address.');
return;
}
if (password.length < 4) {
alert('Please enter a password.');
return;
}*/
firebase.auth().createUserWithEmailAndPassword(email, password).catch(
function (error)
{
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// [START_EXCLUDE]
if (errorCode == 'auth/weak-password') {
alert('The password is too weak.');
} else {
alert(errorMessage);
}
if (errorCode == 'auth/argument-error') {
alert('Error with arg');
} else {
alert(errorMessage);
}
console.log(error);
// [END_EXCLUDE]
});
// [END createwithemail]
};
$scope.login = function () {
firebase.auth().onAuthStateChanged(function (user) {
if (user) {
// User is signed in.
alert("User already signed in");
} else {
// No user is signed in.
firebase.auth().signInWithEmailAndPassword(email, password).catch(
function (error)
{
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
alert("error during login:" + errorMessage + "Code: " + errorCode);
})
}
});
};
$scope.openModal = function () {
$scope.modal.show();
};
$scope.closeModal = function () {
$scope.modal.hide();
};
// Cleanup the modal when we're done with it!
$scope.$on('$destroy', function () {
$scope.modal.remove();
});
// Execute action on hide modal
$scope.$on('modal.hidden', function () {
// Execute action
});
// Execute action on remove modal
$scope.$on('modal.removed', function () {
// Execute action
});
}]);
请注意app.js包含两个控制器,因为如果用户点击右上角的按钮,一个模态会打开另一个模态
此功能放在app.js中,只是想为你突出显示它。
$scope.signupEmail = function () {
$scope.data = {};
var email = $scope.data.email;
alert(email);
var password = $scope.data.password;
alert(password);
firebase.auth().createUserWithEmailAndPassword(email, password).catch(
function (error)
{
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// [START_EXCLUDE]
if (errorCode == 'auth/weak-password') {
alert('The password is too weak.');
} else {
alert(errorMessage);
}
if (errorCode == 'auth/argument-error') {
alert('Error with arg');
} else {
alert(errorMessage);
}
console.log(error);
// [END_EXCLUDE]
});
// [END createwithemail]
};
注意:正如您所看到的那样,我打印出密码并通过电子邮件发送用户输入的内容以查看其值,但我得到的唯一结果是
我做错了什么? 非常感谢您的回答。
谢谢!
答案 0 :(得分:0)
var outDir = './src/css'; // output folder for CSS
gulp.task('min:css', function () {
return gulp
.src(cssInput)
.pipe(postcss([
autoprefixer(),
postcssurl({
// this function will modify URLs
url: function (asset) {
if (!asset.url || asset.url.indexOf("base64") !== -1) {
return asset.url;
}
return path.relative(outDir, asset.absolutePath).split("\\").join("/");
}
})
]))
...
});
电子邮件始终未定义。