Angular 使用AoT预编译组件工厂进行JiT编译

Angular 使用AoT预编译组件工厂进行JiT编译,angular,angular-aot,angular-compiler,Angular,Angular Aot,Angular Compiler,我有一个来自后端的随机标记,应该在运行时用JiT编译。此标记中使用的每个组件都已使用AoT(添加到entryComponents块)预编译,因此在运行时具有组件工厂。JiT编译提供的标记时,会忽略现有组件工厂并重新编译每个内部组件。 有没有办法将组件的AoT预编译工厂提供给JiT编译器,以便使用动态模板只编译一个动态组件 应该编译的标记如下所示 <exercise1 smth="smth"> <exercise1-answer>smth</exercise1-a

我有一个来自后端的随机标记,应该在运行时用JiT编译。此标记中使用的每个组件都已使用AoT(添加到entryComponents块)预编译,因此在运行时具有组件工厂。JiT编译提供的标记时,会忽略现有组件工厂并重新编译每个内部组件。
有没有办法将组件的AoT预编译工厂提供给JiT编译器,以便使用动态模板只编译一个动态组件

应该编译的标记如下所示

<exercise1 smth="smth">
  <exercise1-answer>smth</exercise1-answer>
</exercise1>
<some-wrapper-cmp>
  <exercise2 smth="smth">
    <exercise2-answer>smth</exercise2-answer>
  </exercise2>
</some-wrapper-cmp>

请添加更多具体示例。也许你可以用你的问题来创建github存储库你的意思是什么?我添加了一个makrup示例并对其进行了评论。来自标记的哪些组件已经预编译过工厂?您正在向动态模块添加哪些组件?如果您提供了一个最小的复制版本,您会更好地理解标记中的每个组件都是预编译的,我只需要在运行时通过动态创建的组件编译这个模板(应该通过JiT编译它)@drow您是否解决过您的问题。我遇到了同样的事情。使用动态JIT编译组件中的AOT编译组件。
const component = Component({ template })(class {});
const module = NgModule({ imports, declarations: [ component ], schemas })(class {});

this.compiler.compileModuleAndAllComponentsAsync(module)
  .then(factories => factories.componentFactories.filter(factory => factory.componentType === component)[0])
  .then(componentFactory => {
    this.componentRef = this.viewContainerRef.createComponent(
      componentFactory,
      null,
      this.viewContainerRef.injector
    );

    this.compilationEnd.emit();
  });`enter code here`