Ionic 4 Lazy Loading and Modals

So at the end this thread never solve and given correct example how to LAZY LOADING modal.

So basically it is not working, even not the way they show in the official docs.
Looks like we have to forget about lazy loading a modal…too bad.

After I have tried, the modal unable to independently lazy load. It has to tie with other modules to lazy load.

e.g. app-routing.module.ts

 const routes: Routes = [
   {
    path: 'MyPage', 
    loadChildren: () => import('../my/my.module').then( m => m.MyModule)
   }
 ];
 
 @NgModule({
   imports: [
     RouterModule.forRoot(
       routes,
       { preloadingStrategy: PreloadAllModules}
     )],
   exports: [RouterModule]
 })
 export class AppRoutingModule { }

e.g. MyModule.ts <- lazy module

@NgModule({
     declarations: [MyPage],
     imports: [
         RouterModule.forChild([{ path: '', component: MyPage }]),
         MeProfileModalPageModule <-- this modal has to lazy load with other module
     ],
     exports:[
         MyPage
     ]
   })
   export class MyModule { }

And the MeProfileModalPageModule have to remove all the route from Angular.

e.g. MeProfileModalPageModule <- unable lazy module

@NgModule({
    declarations: [MeProfileModalPage],
    imports: [
    ],
    exports: [
        MeProfileModalPage
    ]
  })
  export class MeProfileModalPageModule { }
1 Like