convert createNgModule to standalone components in Angular

99 Views Asked by At

I converted all components to standalone. In some places however I didn´t remove the modules. Instead I´m importing the main component inside each otherwise empty module:

@NgModule({
  imports: [
    MyComponent,
  ],
})
export class MyModule {}

The reason: I have a batch process (started with a button) which needs content from other components. I only want to lazy load those components when the process is started and not whenever the button (to start the process) is loaded. Therefore I currently load modules manually like this:

from(import('./path-to-module/my-module.module')).pipe(
  switchMap(({ MyModule}) =>
    of(createNgModule(MyModule, this.injector))
  )
);

How can I convert this code to work with standalone components directly instead of those basically empty modules?

0

There are 0 best solutions below