1

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.

Vijay
  • 23
  • 7
  • 1
    Does this answer your question? [Lazy loading Angular 13+ modules without the deprecated compiler](https://stackoverflow.com/questions/70204754/lazy-loading-angular-13-modules-without-the-deprecated-compiler) – Eric Phillips May 04 '22 at 13:03
  • it doesnot as that one is just creating a module, here I am finding one then creating – Vijay May 04 '22 at 13:10

1 Answers1

0

Without using the factory, you have to use ViewContainerRef.createComponent. refer to the below link https://stackoverflow.com/a/72174262/19077843

Siva Gokul
  • 81
  • 1
  • 4
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 12 '22 at 01:06