Ionic 2/3:
As you can see in the AlertController docs , you can use the option enableBackdropDismiss(boolean) when creating an alert:
enableBackdropDismiss : whether to disable the warning by touching the background. True by default
import { AlertController } from 'ionic-angular';
export class MyPage {
constructor(public alertCtrl: AlertController) {}
showAlert() {
let alert = this.alertCtrl.create({
title: 'New Friend!',
subTitle: 'Your friend, Obi wan Kenobi, just accepted your friend request!',
buttons: ['OK'],
enableBackdropDismiss: false
});
alert.present();
}
}
4:
Ionic 4 backdropDismiss:
backgroundDismiss: true .
import { AlertController } from '@ionic/angular';
export class MyPage {
constructor(public alertController: AlertController) {}
async showAlert() {
const alert = await this.alertController.create({
header: 'Alert',
subHeader: 'Subtitle',
message: 'This is an alert message.',
buttons: ['OK'],
backdropDismiss: false
});
await alert.present();
}
}