【发布时间】:2020-02-27 16:37:00
【问题描述】:
我有两个模块。我需要在对话框中显示组件。但是该组件在其中导入了几个组件(超过 20 个)。因此,如果有一个组件,我会在公共模块中创建。但这更复杂。我尝试从另一个模块导出组件。但这会给我一个错误,因为它没有在这个模块的入口组件中声明。
@NgModule({
declarations: [
DocumentEditComponent,
TestimonialLieuComponent,
CommNetworkAddDialogComponent,
GoalComponent,
InterviewGuideComponent,
JobCommunicationComponent,
LearningComponent,
MatchConfigComponent,
PayDetailComponent,
PerksAndBenefitsComponent,
QuestionnaireComponent,
VendorComponents,
WorkRelatedComponent,
ConfigurationComponent,
BasicInfoComponent,
AddDialogComponent,
JdmDetailAddComponent,
JdmDetailComponentComponent,
InterviewGuideMapComponent,
AdminOrgJdmComponent,
AdminOrgJdmDetailComponent,
OrgJdmAddComponent,
OrgInterviewGuideComponent,
OrgExperienceComponent,
OrgCommNetworkComponent,
OrgWorkRelatedComponent
],
exports: [
TestimonialTemplateComponent,
TestimonialComponent,
AdminOrgJdmDetailComponent
],
imports: [
CommonModule,
TapCommonModule,
RecruitmentConfigRoutingModule
],
entryComponents: [
PhysicaldemandEditOrgComponent,
InterviewProcessComponent,
AssessmentsComponent,
CareerPathComponent,
DocumentComponent,
ExperienceComponent,
GoalComponent,
InterviewGuideComponent,
JobCommunicationComponent,
LearningComponent,
MatchConfigComponent,
PayDetailComponent,
PerksAndBenefitsComponent,
QuestionnaireComponent,
VendorComponents,
WorkRelatedComponent,
ConfigurationComponent,
AddDialogComponent,
JdmDetailAddComponent,
InterviewGuideMapComponent,
OrgJdmAddComponent,
AssessmentOrgAddComponent,
CareerPathOrgAddComponent,
],
providers: []
})
export class RecruitmentConfigModule {
}
并在对话框中调用组件
openJD(): void {
let dialogRef = this.dialog.open(AdminOrgJdmDetailComponent, {
width: '80%',
data: this.jobDescription,
height: '90%',
disableClose: true
});
dialogRef.afterClosed().subscribe(result => {
});
}
这会引发错误
VM60232 JobRequisitionAddFormComponent.ngfactory.js:230 错误错误:找不到 AdminOrgJdmDetailComponent 的组件工厂。你把它添加到@NgModule.entryComponents 了吗?
任何其他方法来解决这个问题。请告诉我
【问题讨论】:
-
错误提示该怎么做。 “……你把它添加到@NgModule.entryComponents 了吗?” AdminOrgJdmDetailComponent 需要在入口组件中。
-
@OneLunchMan 是的,我明白了。但是如果我在我正在使用的两个模块中导入所有组件。我认为这不是正确的方法。可能有解决方案。
-
评论(和下面的答案)并没有说要导入两个模块中的所有组件。此评论和其他答案是说将其添加到它声明和导出的模块的条目组件中。请参阅文档以获取更多信息。 angular.io/guide/architecture-modules#ngmodule-metadata
标签: angular