對於角和離子都是新的。我在我的頁面中有一個彈出窗口,我向用戶顯示輸入字段以輸入OTP和提交按鈕。當我提交按鈕點擊,我做檢查的Ajax調用如果OTP是有效的。離子關閉IonicPopup當按鈕發出Ajax呼叫時
,但我不能與.close方法關閉彈出。請幫助
var OTPPopup = $ionicPopup.show({
title: 'OTP VERIFICATION',
templateUrl: 'templates/login/otp.html',
scope: $scope,
buttons : [{
text: 'Confirm OTP',
type: 'button-assertive',
onTap : function(e) {
e.preventDefault();
var validateResponse = validateOTP();
validateResponse.then(function(response){
console.log('success', response);
return response;
});
}
}]
}).then(function(result){
console.log('Tapped', result);
OTPPopup.close();
});
及以下功能validateOTP
function validateOTP() {
var requestObj = {
authentication: {
email_id: $scope.loginForm.email,
security_code: $scope.OTP
}
};
return $q(function(resolve, reject) {
activateUser(requestObj, function(response){
if(response.error == null && response.data.isSuccess) {
console.log('validate correct');
resolve(response);
}
}, function(response){
return 'error';
});
});
}
activateUser
是我的服務,這使得Ajax調用。請讓我知道我該如何實現這一目標。
console.log('success', response)
被打印在.then
裏面,但在從onTap
返回一些東西后,彈出窗口的承諾沒有被調用。
這真的很有幫助。當請求經過並轉換到我的應用程序的另一個狀態時,我遇到了彈出式關閉問題。它會被卡住。這是強制關閉離子彈出的最佳方式 – Flash