I'm reading https://blog.nrwl.io/essential-angular-ngmodules-16474ea99713 By Victor Savkin and I'm a bit lost on Lazyloading NgModuleFactoryLoader
.
Lazy Loading As I mentioned above NgModules are not just the units of compilation, they are also the units of distribution. That is why we bootstrap an NgModule, and not a component — we don’t distribute components, we distribute modules. And that’s why we lazy load NgModules as well.
When using NgModuleFactoryLoader
what part of the NgModule does the param path inside .load()
point to?
import {NgModuleFactoryLoader, Injector} from '@angular/core';
class MyService {
constructor(loader: NgModuleFactoryLoader, injector: Injector) {
loader.load("mymodule").then((f: NgModuleFactory) => {
const moduleRef = f.create(injector);
moduleRef.injector; // module injector
moduleRef.componentFactoryResolver; // all the components factories of the lazy-loaded module
});
}
}
Question:
How can I reference ExampleModule
inside of NgModuleFactoryLoader.load(???)
@NgModule({
imports: [ModuleA, ModuleB]
})
class ExampleModule {
constructor() {
}
}