How to use Observables instead of Events to listen to dismiss event in Angular Ionic


I’m using ionic’s inline modal, which’s triggered by a boolean. However, when the modal is dismissed, the boolean is not automatically set to zero. According to ionic’s documentation, "Developers should listen for the ionModalDidDismiss or didDismiss event and set isOpen to false. Unfortunately, they provide no further information on how to do so. Ionic had an Events module, but it was deprecated in exchange for using Observables. And now I’m stuck.

I tried to look for sources that explain how observables could be used in lieu of ionic’s Events but to no avail. To summarize: I want to listen to a DOM dismiss event from ionic-modal and then set the isOpen boolean that triggers the modal to false. How can I use Observables to listen to events? What alternatives are there?


I don’t think you need to use observables, I think it’s as simple as setting a variable to false:

<ion-modal (ionModalDidDismiss)="isModalOpen = false">

Answered By – BizzyBob

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published