加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Angular 4:没有找到组件工厂,你是否将它添加到@ NgModule.entry

发布时间:2020-12-17 08:02:22 所属栏目:安全 来源:网络整理
导读:我正在使用带有webpack的Angular 4模板 当我尝试使用组件(ConfirmComponent)时出现此错误: No component factory found for ConfirmComponent. Did you add it to @NgModule.entryComponents? 组件在app.module.server.ts中声明 NgModule({ bootstrap: [ Ap
我正在使用带有webpack的Angular 4模板
当我尝试使用组件(ConfirmComponent)时出现此错误:

No component factory found for ConfirmComponent. Did you add it to
@NgModule.entryComponents?

组件在app.module.server.ts中声明

NgModule({
    bootstrap: [ AppComponent ],imports: [
     ...
    ],entryComponents: [
        ConfirmComponent,],})
export class AppModule {
}

我还有app.module.browser.ts和app.module.shared.ts

如何解决这个问题。
谢谢

在你的module.ts中添加这个,
declarations: [
     AppComponent,ConfirmComponent
  ]

如果ConfirmComponent在另一个模块中,你需要将它导出到那里,这样你可以在外面使用它,添加:

exports: [ ConfirmComponent ]

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读