文章内容

2020/7/29 10:50:15,作 者: 黄兵

no component factory found,did you add it to @NgModule.entryComponents?

最近禁用Ivy,具体配置如下:

tsconfig.json:

"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"enableIvy": false,
"strictInjectionParameters": true
}

编译项目,部署之后有一些动态加载项目,报如下错误:

no component factory found,did you add it to @NgModule.entryComponents?

解决方案:

对于动态加载的组件,为了生成ComponentFactory,还必须将该组件添加到模块的entryComponents中:

app.module.ts:

entryComponents: [
ShareDialogComponent,
DialogOverviewHelpDialog,
HeaderSearchDialogComponent,
SMSContentDialogComponent,
SMSContentSearchDialogComponent,
NotificationOverviewDialogComponent
],

这里将所有的Dialog组件加入到entryComponents中。


参考资料:

1、Angular 4: no component factory found,did you add it to @NgModule.entryComponents?


黄兵个人博客原创。

转载请注明出处:黄兵个人博客 - no component factory found,did you add it to @NgModule.entryComponents?

分享到:

发表评论

评论列表

user-ico

招标问答 on 回复 有用(0

虽然没遇到过 还是支持一下博主 欢迎回访哦

游客K*<n on 2020-07-31 17:12:53

博主回复:已回访。