禁用背景点击离子警报

时间:2017-03-22 12:06:49

标签: ios ionic-framework alert

我正在使用离子来为ios和android增加移动应用程序。在我的应用程序中显示任何离子警报时,当我点击背景而不是后台功能工作。我想要禁用它。 我的提示框代码是:

var alertPopup = $ionicPopup.alert({
       title: 'Alert',
       template: 'Please fill all fields first.'
   })
   .then(function(res) {
        // some code
    });

这将显示移动设备上的警告框,但是当我点击背景侧而不是背景功能时,我想停止此操作。

例如:我有一个包含多个字段的表单。我点击了提交按钮,显示了警告信息。当我点击" ok"警告按钮后面的输入框是" ok"按钮也被触发了。所以我想阻止这一点。

我搜索了这个问题,但没有找到任何东西。

2 个答案:

答案 0 :(得分:0)

试试这个

HTML

<html ng-app="mySuperApp">
  <head>
    <meta charset="utf-8">
    <title>
      Popups
    </title>

    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">

    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>

  </head>
  <body class="padding" ng-controller="PopupCtrl">

    <button class="button button-positive" ng-click="showAlert()">
      Alert
    </button>

  </body>
</html>

app.js

angular.module('mySuperApp', ['ionic'])
.controller('PopupCtrl',function($scope, $ionicPopup, $timeout) {

   // An alert dialog
   $scope.showAlert = function() {
     var alertPopup = $ionicPopup.alert({
       title: 'Alert',
       template: 'Please fill all fields first.'
     });
     alertPopup.then(function(res) {
       console.log('something');
     });
   };

答案 1 :(得分:-1)

将此选项 enableBackdropDismiss 放入.create对象中,并为其分配false

相关问题