[英]Ionic popup alert not closing properly
The first alert verifies whether the entered password corresponds to the user's password If it does, then opens another alert where the user change the password if he has entered the same password in both fields And finally, the third alert will open if it has successfully changed the password 第一个警报将验证输入的密码是否与用户的密码相对应(如果是),然后打开另一个警报,如果用户在两个字段中都输入了相同的密码,则用户将在其中更改密码。最后,如果第三个警报已成功更改,则将打开密码
The problem occurs if I click Cancel in the second alert or after confirming the third alert After that, I'm not able to click on anything inside the app until I unload and restart the same application 如果我在第二个警报中单击“取消”或在确认第三个警报后单击“确定”,则会出现问题。
So I guess the problem occurs because the alert is not closed properly 所以我猜可能是因为警报未正确关闭而发生问题
Here is my code: 这是我的代码:
$scope.changePass = function () {
$scope.newitem = {}
var myPopup = $ionicPopup.alert({
template: '<input type="password" placeholder="password" ng-model="newitem.password">',
title: 'Insert your password',
scope: $scope,
buttons: [
{ text: 'Cancel' },
{
text: '<b>Confirm</b>',
type: 'button-positive',
onTap: function(e) {
if (!$scope.newitem.password) {
console.log("preventing default");
e.preventDefault();
} else {
if($scope.newitem.password == $scope.user.password) {
$scope.new = {}
var newPass = $ionicPopup.alert({
template: '<input type="password" placeholder="password" ng-model="new.newpass"><br><input type="password" placeholder="Repeat password" ng-model="new.repeatpass">',
title: 'Insert your new password',
scope: $scope,
buttons: [
{ text: 'Cancel' },
{
text: '<b>Confirm</b>',
type: 'button-positive',
onTap: function(e) {
if (!$scope.new.newpass) {
console.log("preventing default");
e.preventDefault();
} else {
if (!$scope.new.repeatpass) {
$scope.new.newpass = "";
console.log("preventing default");
e.preventDefault();
} else {
if ($scope.new.newpass == $scope.new.repeatpass) {
$scope.user.password = $scope.new.newpass;
var uri = "http://someLink" + $window.localStorage.id;
$http({
method: 'PUT',
url: uri,
headers: {"Content-Type": "application/json;charset=UTF-8"},
data: $scope.user
}).success(function() {
var succesResponse = $ionicPopup.alert({
title: 'Ok',
template: "Password has changed"
});
succesResponse;
e.preventDefault();
});
}
else {
$scope.new.newpass = "";
$scope.new.repeatpass = "";
e.preventDefault();
}
}
}
}
}
]
});
}
else {
$scope.newitem.password = "";
e.preventDefault();
}
}
}
}
]
});
}
I found the answer to my question 我找到了问题的答案
Namely, the solution is to close the first alert before I open the second alert But before I open second alert, it is necessary to have a timeout to close the first alert properly 即,解决方案是在打开第二个警报之前关闭第一个警报,但是在打开第二个警报之前,必须有一个超时时间才能正确关闭第一个警报
myPopup.close();
$timeout(function() {
$scope.new = {}
var newPass = $ionicPopup.alert({...});
}, 500);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.