Suppose I have the following LazyModule
that is lazily loaded and the LazyComponent
declared inside of it:
@NgModule({
declarations: [LazyComponent],
providers: [LazyModuleService],
})
export class LazyModule { ...
@Component({
selector: 'my-lazy',
providers: [LazyComponentService]
})
export class LazyComponent { ...
My understanding is that when loading LazyModule
angular will create a child injector for this module from rootInjector
, something like this:
var lazyModuleInjector = rootInjector.resolveAndCreateChild([LazyModuleService]);
and then create a child injector for LazyComponent
like this:
var lazyModuleInjector = lazyModuleInjector.resolveAndCreateChild([LazyComponentService]);
So eventually the injector tree be like this:
Is it correct?