angular - 如何在当前模块中使用其他模块的组件?
问题描述
我有两个模块。我需要在对话框中显示组件。但是该组件在其中导入了几个组件(超过 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 了吗?
任何其他方法来解决这个问题。请告诉我
解决方案
我会尝试将 AdminOrgJdmDetailComponent 添加到 entryComponents 数组中。正如错误所说,在那里找不到它。由于您以动态方式加载它,我认为您必须告诉 Angular 强制加载它。
...
entryComponents: [
...
AdminOrgJdmDetailComponent
],
...
你可以在这里找到更多信息。
推荐阅读
- sql - 用其他表中的值替换选择值
- mobile-application - 通知用户有移动应用程序的原生方式?
- r - 获取具有两个变量和多个行名的 p 值
- algorithm - 非随机访问结构中二进制搜索的复杂性
- python - 修改包含 nan 的 pandas 列的值
- php - php文件被识别但没有输入
- swift - 两个 ios 设备之间的后台扫描和广告
- amazon-web-services - 如何添加 EMR Spark 步骤?
- reactjs - React Typescript - 将道具传递给 Hooks 之间的类型错误
- python - 如何在 django 模板中使用大于运算符