Search code examples
angularionic-frameworkionic2

How to dismiss all popups at the platform resume?


In my application, I have this alert:

let confirm = this.alertCtrl.create({
                    title: 'Blabla',
                    message: 'blablabla',
                    buttons: [button1, button2, button3],
                    enableBackdropDismiss: false
                });
                confirm.present();

Also, when the application is resumed, the application should redirect to login page. No problem in making that work.

The problem comes, when I open the popup and resume the application. The application does redirect correctly, but the popup remains opened.

Is there a solution to programatically close all the popups opened? The resume function is called from app.component:

this.platform.resume.subscribe(() => {});

For this reason I cannot call confirm variable and close this popup.


Solution

  • You can subscribe to the same event from different places. So, you can call this.platform.resume.subscribe(() => {}); from the component where your confirm variable is accessible.