我正在使用ngx-admin模板。现在,我正在尝试创建一个将在单击按钮时打开的模式。我试图在模式窗口中显示一个表单,但是在单击时,模式确实打开了,但没有显示该表单,并且出现此错误
未找到EmailInstructorsComponent的组件工厂。您是否将其添加到@ NgModule.entryComponents?
我正在使用惰性装载,并且大多数模块已添加到shared.module文件的声明中,以避免在生产过程中出错。 我也尝试查看stackoverflow上可用的其他链接,但是它们都没有引用modal-windows / dialogs,这就是为什么我必须创建这个单独的线程
classes-and-students.module.ts文件
const ENTRY_COMPONENTS = [
EmailInstructorsComponent
];
@NgModule({
imports: [
ClassesAndStudentsRoutingModule,
NbCardModule,
Ng2SmartTableModule,
NbAlertModule,
SharedModule,
CKEditorModule
],
declarations: [
ClassesAndStudentsComponent,
...routedComponents,
InstructorbiddingComponent,
EmailInstructorsComponent,
],
entryComponents: [
...ENTRY_COMPONENTS
],
providers: [
NewsService,
],
})
export class ClassesandStudentsModule { }
instructorbidding.component.ts文件
@Component({
selector: 'ngx-instructorbidding',
templateUrl: 'instructorbidding.component.html',
styleUrls: ['instructorbidding.component.scss']
})
export class InstructorbiddingComponent {
@ViewChild('contentTemplate', { static: true }) contentTemplate: TemplateRef<any>;
@ViewChild('disabledEsc', { read: TemplateRef, static: true }) disabledEscTemplate: TemplateRef<HTMLElement>;
constructor(private windowService: NbWindowService) { }
openWindowForm(contentTemplate) {
this.windowService.open(EmailInstructorsComponent, { title: 'Window'});
}
}
email-instructors.component.ts文件
@Component({
selector: 'ngx-email-instructors',
templateUrl: './email-instructors.component.html',
styleUrls: ['./email-instructors.component.scss']
})
export class EmailInstructorsComponent {
constructor(public windowRef: NbWindowRef) {
}
close() {
this.windowRef.close();
}
}
email-instructors.component.html文件
<form class="form">
<label for="subject">Subject:</label>
<input nbInput id="subject" type="text">
<label class="text-label" for="text">Text:</label>
<textarea nbInput id="text"></textarea>
</form>
我不确定自己犯了什么错误,因此请指出我的错误来帮助我
答案 0 :(得分:3)
尝试像这样更改您的代码,以查看其是否有效
const ENTRY_COMPONENTS = [
EmailInstructorsComponent
];
@NgModule({
imports: [
ClassesAndStudentsRoutingModule,
NbCardModule,
Ng2SmartTableModule,
NbAlertModule,
SharedModule,
CKEditorModule
],
declarations: [
ClassesAndStudentsComponent,
...routedComponents,
InstructorbiddingComponent,
EmailInstructorsComponent,
],
entryComponents: [
ENTRY_COMPONENTS
],
providers: [
NewsService,
],
})
export class ClassesandStudentsModule { }