How to listen to didDismiss event when using Inline Modals

I use Inline Modals in my code, and I want to use isOpen property to control the opening and closing of the model,
since I use buttons to control the opening and closing, I need to “know” when the model closes, to do this and according to the documentation:

Developers need to listen for the ionModalDidDismiss or didDismiss events and set the reactive variable to false themselves.

All the examples on the Internet that I have seen on the subject, explained to cases that use Controller Modals and not Inline Modals,

It should be noted that a solution by using trigger property instead of isOpen will not help in my specific case, as I need two buttons to control the opening and closing of the model, and a trigger is only useful for one button.

Here is the code:

<ion-content>
  <ion-button class="toggleDisplayModal1"></ion-button>
  <ion-button class="toggleDisplayModal2"></ion-button>
</ion-content>

<ion-footer>
  <ion-modal class="ionModal"  [isOpen]="isModelOpen" >
    <ng-template >
      <ion-content >
         <my-content/>
      </ion-content>
    </ng-template>
  </ion-modal>
</ion-footer>

I’m new to ionic and angular, and I do not understand how I do it, so I would be happy if something would explain to me, thanks!

Hi

The angular way will require you to use ViewChild to reference to the Ion-modal element and then use that as per documentation to await the dismiss handler

A very brief explanation which may or may not help pending your experience in angular

1 Like