DEV Community

Discussion on: Angular 9: Lazy Loading Components

Collapse
 
layzee profile image
Lars Gyrup Brink Nielsen • Edited

John, we can use feature render modules to use child components in the template instead of this imperative approach. We should remember to pass the injector along to the embedded views to enable dependency injection.

An upcoming alternative to ViewContainerRef#createComponent is renderComponent.

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
layzee profile image
Lars Gyrup Brink Nielsen • Edited

Another way to switch from an imperative approach to a declarative approach is to use *ngComponentOutlet instead of ViewContainerRef#createComponent.