Prevent Multiple Ionic Alerts

How can I determine if the ionic 2 alert ui component is open so as not to show another warning?

+6
source share
1 answer

I ended up writing a migration provider for the Ionic Alert controller as follows:

import { Injectable } from '@angular/core'; import { AlertController } from 'ionic-angular'; @Injectable() export class Alert { public alertPresented: any; constructor(public alertCtrl: AlertController) { this.alertPresented = false } present(title, subTitle) { let vm = this if(!vm.alertPresented) { vm.alertPresented = true vm.alertCtrl.create({ title: title, subTitle: subTitle, buttons: [{ text: 'OK', handler: () => { vm.alertPresented = false } }], }).present(); } } } 

where the alertPresented flag prevents the submission of more than one instance

+4
source

All Articles