1

In my CRM system I have dashboards all over the place. For adding widget to dashboard I use modals. I want to lazy load module that is responsible for adding modals. I though it is possible since angular@9 but I think it is not :/

When I press propper button it executes this code:

openModal(): Observable<WidzetModel> {
    const obs$ = from(
      import('@app/widgets/widgets-add.module')
    )
      .pipe(
        switchMap(resp => {
          return this.modalService.open(ModalAddWidgetComponent)
            .pipe(take(1));
        }));
  }

Module is lazy loaded but it is not initiated. For example none of providers are initiated:

@NgModule({
  declarations: [],
  imports: [],
  providers: [
    WidgetAddService
  ],
})
export class WidgetsAddModule {
}

So is it possible to lazy load modules outside router?

piernik
  • 3,507
  • 3
  • 42
  • 84
  • Does this answer your question? [How to manually lazy load a module?](https://stackoverflow.com/questions/40293240/how-to-manually-lazy-load-a-module) – Guerric P Apr 09 '20 at 10:31
  • I want specific Angular@9 which should bring some changes in lazy loading – piernik Apr 09 '20 at 10:46

0 Answers0