How to dismiss multiple modals in ionic v4? solution is here!


Using Ionic v4 Create Multiple modals . we can hide modal by using dismiss() . but it hide only top overlay modal. need to hide appropriate modal. here is a solution

first you need to create ionic modal using by Modal Options
after mention component in modal options, beneath that need to mention modal id

 async ShowEmployeelistModel(){
    const modal = await this.modalCtrl.create({
      component: EmployeeListComponent,
    return await modal.present();

above code show you how to create modal with id

now if you want to hide that modal

in dismiss method need to pass id as parameter

 this.modalCtrl.dismiss(null, null, "FlowEmployee");

above code mention that passing parameter .
first one parameter is data optional
second one role optional
third one id optional


in the above code . i did not mention id . so it will dismiss top overlay modal

1 Like