Ionic 4 Angular - How to self dismiss a modal

Eliya Cohen picture Eliya Cohen · Sep 23, 2018 · Viewed 16.4k times · Source

In Ionic 3, dismissing a modal was pretty simple:

constructor(viewCtrl: ViewController) {
    this.viewCtrl.dismiss()
}

In Ionic 4, I can't import ViewController (or to be accurate, my IDE tries to import a type of ViewController).

I was wondering what the new approach of dismissing a modal is.

Answer

Eliya Cohen picture Eliya Cohen · Sep 23, 2018

According to the docs, it looks like the dismiss method has moved to ModalController.

So to dismiss a modal, I need to do:

constructor(modalCtrl: ModalController) {
  modalCtrl.dismiss();
}

How ironic that I find my answer AFTER I post the question.