【问题标题】:ERROR Error: No component factory found for TestComponentERROR 错误:未找到 TestComponent 的组件工厂
【发布时间】:2020-07-01 11:51:41
【问题描述】:

我添加了一个新组件,

   MlP8DocumentComponent

在 app.module.ts 中添加,

       declarations: [MlP8DocumentComponent, MlAmendmentDetailsComponent],
       entryComponents:[MlP8DocumentComponent, MlAmendmentDetailsComponent]

当我尝试访问它时,我点击了一个标签,

    switch (section) {
    case 'amendmentDetails': {
      factory = this.resolver.resolveComponentFactory(MlAmendmentDetailsComponent);
      break;
    }
    case 'p8documents': {
      factory = this.resolver.resolveComponentFactory(MlP8DocumentComponent);
      break;
    }
  }

它说错误

     MlSummaryComponent.html:3 ERROR Error: No component factory found for MlP8DocumentComponent. Did you add it to @NgModule.entryComponents?

entrycomponent 中的其他组件运行良好。谁能帮帮我。谢谢。

【问题讨论】:

  • 我已经根据我掌握的信息进行了回答,如果这不能解决您的问题,请为它制作一个 Stackblitz。

标签: angular angular6 mean-stack angular-components


【解决方案1】:

如果您尝试在其他模块中使用此组件,则需要将其添加到该模块的 entrycomponents 中,并将其导出到您的 app.module.ts

exports: [MlP8DocumentComponent]

【讨论】:

  • 嗨 CodeWarior,我在同一个组件中使用它。我刚刚创建了该组件并包含在 entryComponents 中。请帮助我。
  • 你可以为它制作一个 Stackblitz 吗?
  • 嘿,我查看了您的 Stackblitz,它按预期工作。两个组件都在加载。问题出在哪里?
  • 感谢 CodeWarrior,问题出在我的构建上。已解决。
猜你喜欢
  • 2019-03-02
  • 1970-01-01
  • 2019-07-10
  • 2019-02-18
  • 2019-03-13
  • 2020-03-08
  • 2018-05-06
  • 2017-02-15
  • 1970-01-01
相关资源
最近更新 更多