Angularjs 爱奥尼亚-需要电子邮件/密码
我有身份验证我的登录时,错误的电子邮件格式,电子邮件或密码,它将显示一个弹出错误。然而,若并没有在电子邮件和密码中输入任何内容,它将卡在加载页面上。有人有办法吗 login.htmlAngularjs 爱奥尼亚-需要电子邮件/密码,angularjs,cordova,ionic-framework,Angularjs,Cordova,Ionic Framework,我有身份验证我的登录时,错误的电子邮件格式,电子邮件或密码,它将显示一个弹出错误。然而,若并没有在电子邮件和密码中输入任何内容,它将卡在加载页面上。有人有办法吗 login.html <ion-view title="Login" hide-nav-bar="true" hide-back-button="true" id="page6"> <ion-content padding="true" style="background: url(img/fOM24l77Sr
<ion-view title="Login" hide-nav-bar="true" hide-back-button="true" id="page6">
<ion-content padding="true" style="background: url(img/fOM24l77SrSIyzBwqvMz_login.jpg) no-repeat center;background-size:cover;" class="manual-ios-statusbar-padding">
<div class="spacer" style="width: 300px; height: 82px;"></div>
<h4 style="color: #FFFFFF;" align="center">Login with your NYP SIT account</h4>
<form name="loginForm" class="list " id="login-form1">
<ion-list class=" " id="login-list2">
<div class="app-icon"></div>
<label class="item item-input item-floating-label">
<span class="input-label" style="color: #9F9F9F;">Email</span>
<input ng-model="user.email" style="color: white;" type="email" placeholder="Email">
</label>
<label class="item item-input item-floating-label">
<span class="input-label" style="color: #9F9F9F;" >Password</span>
<input ng-model="user.password" style="color: white;" type="password" placeholder="Password">
</label>
</ion-list>
<div style="height: 40px;" class="spacer"></div>
<button ng-click="loginEmail(loginForm,user)" class=" button button-assertive button-block icon-left ion-ios-email-outline " id="signup-button3">LOGIN WITH EMAIL</button>
</form>
</ion-content>
</ion-view>
})我认为最好检查字段是否为空。如果字段为空,则可以显示错误消息
$scope.loginEmail = function(formName, cred) {
if (formName && cred) { //checking for null
if (formName.$valid) { // Check if the form data is valid or not
sharedUtils.showLoading(); //starts the loading popup
//Email Login via Firebase
firebase.auth().signInWithEmailAndPassword(cred.email, cred.password).then(function(result) {
$ionicHistory.nextViewOptions({
historyRoot: true //1
});
$rootScope.extras = true; //2
sharedUtils.hideLoading(); //3
$state.go('tabs.home', {}, {
location: "replace"
}); //4
},
function(error) {
sharedUtils.hideLoading();
sharedUtils.showAlert("ERROR!", "Authentication Error");
}
);
} else {
sharedUtils.showAlert("ERROR!", "Enter in email format");
}
} else {
sharedUtils.showAlert("ERROR!", "Fields cannot be empty");
}
};
$scope.loginEmail = function(formName, cred) {
if (formName && cred) { //checking for null
if (formName.$valid) { // Check if the form data is valid or not
sharedUtils.showLoading(); //starts the loading popup
//Email Login via Firebase
firebase.auth().signInWithEmailAndPassword(cred.email, cred.password).then(function(result) {
$ionicHistory.nextViewOptions({
historyRoot: true //1
});
$rootScope.extras = true; //2
sharedUtils.hideLoading(); //3
$state.go('tabs.home', {}, {
location: "replace"
}); //4
},
function(error) {
sharedUtils.hideLoading();
sharedUtils.showAlert("ERROR!", "Authentication Error");
}
);
} else {
sharedUtils.showAlert("ERROR!", "Enter in email format");
}
} else {
sharedUtils.showAlert("ERROR!", "Fields cannot be empty");
}
};