Reputation: 63
with Angular 13 I'm seeing deprecations for the usual compiler tools to instantiate an NgModule and Here is my usual go-to code for loading a module
container: ViewContainerRef
const mod = this.compiler.compileModuleAndAllComponentsSync(TemplateModule);
const factory = mod.componentFactories.find((comp) =>
comp.componentType === TemplateComponent
);
const component = this.container.createComponent(factory);
Low-level service for running the angular compiler during runtime to create ComponentFactorys, which can later be used to create and render a Component instance.
Each @NgModule provides an own Compiler to its injector, that will use the directives/pipes of the ng module for compilation of components.
@publicApi
@deprecated Ivy JIT mode doesn't require accessing this symbol. See JIT API changes due to ViewEngine deprecation for additional context.
Looking V13 change for above update.
Upvotes: 1
Views: 2647
Reputation: 91
Without using the factory, you have to use ViewContainerRef.createComponent
.
refer to the below link https://stackoverflow.com/a/72174262/19077843
Upvotes: 0