Is there an event when an Alert is closed?



Is there an event when an Alert is closed or a way to get the same result please ?
I want to push a new page when the alert will be entirely closed.

Thank you

Yes, use onDismiss() to add a handler that will be called when the alert is closed, like this:

var alert = Alert.create({
	title: 'Test',
	message: 'Close the alert.',
	buttons: [ 'OK' ]

alert.onDismiss(() => console.log('The alert has been closed.'));

1 Like

I used OnDismiss() :

this.alert.onDismiss(res => {


As above it doesn’t work. I have a black screen on browser (and white on Android) when my alert dismisses and nothing else happens.

However, if I surround this.nav.push(SettingsPage); with a setTimeout() it works but this is not what I want.
I thank you @iignatov but the onDismiss() is not a solution for me.

I need an event which triggers when the alert is no longer visible.

The behavior you observe is due to a bug in Ionic 2. I also had the same problem in a similar situation. The only workaround that I found is to use setTimeout():

this.alert.onDismiss(res => {
  setTimeout(() => this.nav.push(SettingsPage), 500);

EDIT: Added a link to the related Github issue.

1 Like

Thank you @iignatov for your answers.

I’ll continue to use the setTimeout(); until the bug is fixed.


onDismiss is ok now :slight_smile:
Bug fixed → issues-5818