Using the concept from this answer I have a dynamic angular module loading like this
this.loader.load('app/lazy/lazy.module#LazyModule').then((moduleFactory: NgModuleFactory<any>) => {
const entryComponent = (<any>moduleFactory.moduleType).entry;
const moduleRef = moduleFactory.create(this.inj);
const compFactory = moduleRef.componentFactoryResolver.resolveComponentFactory(entryComponent);
this.container.createComponent(compFactory);
});
I am not using loadChildren, I have the ViewChild, SystemJsNgModuleLoader, and NgModuleFactory all set up which I know because this was successfully loading earlier today. After a restart however, I'm getting the error in the title.
I have tried restarting ng serve with no luck. Why might angular be suddenly unable to locate the lazy module after a restart with barely 15 minutes and no code changes in between?
EDIT: Ok wow, got that working again but have a new question now. I put
providers: [
SystemJsNgModuleLoader,
provideRoutes([
{ loadChildren: 'app/lazy/lazy.module#LazyModule' }
])
]
in app.module.ts, which breaks app at the root instead of when it reaches the factory loader (I think because I am using a separate app.routing file and angular doesn't appreciate multiple routes?) but then when I removed this the lazy module was appearing again!
Restarting ng serve drops it again however, so is there somewhere else I can put the provided route that will work with separate routing? Can I ape whatever is being changed when I compile with provideRoutes in the app.module?