How to open a modal in a lazyloaded page?

How do I open a modal in a lazy loaded page, it just says I have to add it to entrycomponents?, I did add it to entrycomponents. So I don’t get whats wrong.

Using Modals in Ionic3 :

It depends on how you want to open your Modal (Lets say HelloModal)

If it is eagerly loaded Modal, then add it to declarations and entryComponents in app.module.ts, and then in the page which you want to open the modal:

  • import the ModalController and HelloModal in page.ts or component.ts file.
  • Create a variable for ModalController in constructor.
  • Open the modal using this.modalCtrl.create(HelloModal) // Notice there are no single quotes.

If the modal is a lazy loaded modal which has seperate lazy loaded module for modal, then do not declare the modal in app.module.ts:

  • Do not import the modal in the page.ts or component.ts
  • Create a variable for ModalController in constructor.
  • Open the modal using this.modalCtrl.create(‘HelloModal’) // Notice there are single quotes.
1 Like

I tried both ways and neither of them worked. What solved it for now for me was to make sure the Modal looks exactly like any other Ionic Page (with it’s own module), then import the module into the AppModule. What a waste, lazy loading is not friendly in the least T_T

What I don’t get is why your first method didn’t work for me. I am so puzzled.