简体   繁体   English

离子弹出警报无法正确关闭

[英]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.

相关问题 在关闭弹出窗口之前显示警报消息 - Display alert message defore closing a popup window 在关闭的弹出窗口上创建警报消息 - Create alert message on closing popup window 关闭 Javascript 警报后防止关闭 Chrome 扩展弹出窗口 - Prevent closing Chrome extension popup after closing Javascript alert 关闭Sweet Alert弹出窗口并通过AJAX启动另一个甜蜜警报弹出窗口时出现问题 - Problem closing Sweet Alert popup and initiating another sweet alert popup via AJAX 角表达式不能在离子弹出窗口中正确评估 - Angular expression not evaluating properly in Ionic popup 关闭弹出窗口后发出警报,Chrome和Firefox正常,但IE有问题 - An alert after closing popup, fine with Chrome and Firefox, but problems with IE 保存数据之前关闭弹出窗口中显示警报消息? - Before saving the data Closing popup window show alert message? 使用离子的第一步,在按钮点击/点击时获得弹出警报 - First steps with ionic to get popup alert on button tap / click 在模式、警报或仅具有关闭 x 的弹出框中显示来自 html 搜索框的 mysql 查询结果 - Display mysql query result from a html search box in a modal, alert, or just a popup box that has closing x 弹出关闭按钮不关闭弹出 - Popup close button not closing the popup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM