ModalController > ModalModule loaded in page vs in app.module.ts

Hi,

I am using ionic 4, and working with modals.

The problem I have is that my modals only work, in a given page, when I import them directly in the app.module.ts, but If load them in the page’s module (in order for the modals to be loaded when that module loads), then they don’t work.

This is my modal module:

@NgModule({
	declarations: [ScanListModal],
	imports: [
		CommonModule,
		FormsModule,
		IonicModule,
		BasePageModule
	],
	entryComponents: [ScanListModal]
})
export class ScanListModalModule {
}

And this is my page’s module, when loading the modal:


const routes: Routes = [
	{
		path: '',
		component: ScanSessionPage
	}
];

@NgModule({
	imports: [
		CommonModule,
		FormsModule,
		IonicModule,
		RouterModule.forChild(routes),
		BasePageModule,
		CommonComponentsModule,
                ScanListModalModule
	],
	declarations: [ScanSessionPage],
	providers: [],
	entryComponents: [],
	exports: []
})
export class ScanSessionPageModule {
}

And that does not work. But if I remove the import there, and import the modal’s module in app.module.ts, it works.

But my guts tells me that I should just load that modal in the modules that actually use them, not globally for the app, right?

Any help would be appreciated.

Thanks!

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (C:\Users\marti\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.3.1
   @angular-devkit/build-angular : 0.13.8
   @angular-devkit/schematics    : 7.3.8
   @angular/cli                  : 7.3.8
   @ionic/angular-toolkit        : 1.5.1

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : none
   Cordova Plugins       : no whitelisted plugins (0 plugins total)

System:

   Android SDK Tools : 26.1.1 (C:\Users\marti\AppData\Local\Android\sdk)
   NodeJS            : v8.12.0 (C:\Program Files\nodejs\node.exe)
   npm               : 6.9.0
   OS                : Windows 10

Hi
any luck on this? I believe I have a related question. I would not prefer to insert the modalpagemodule at the highest level…

Regards
Tom

No luck. And I don’t understand why Ionic do not reply on this, nor in the support. Because it’s a basic feature.

Hi

I believe this is more about Angular then Ionic, but here is what I did related to shared modals. Not sure if it helps.

If u need response from official support the forum is not the place. For this you need to raise a ticket.

Regards

Tom

I opened a bug request, and they told me to check the code in GitHub, but it is not LazyLoaded, which sucks, frankly.

Check this out and comment, so they take action.

https://github.com/ionic-team/ionic/issues/18411

Thanks!