No component factory found for EmailInstructorsComponent. Did you add it to @NgModule.entryComponents?
我正在使用ngx-admin模板。现在,我正在尝试创建一个将在单击按钮时打开的模式。我试图在模式窗口中显示一个表单,但是在单击时,模式确实打开了,但没有显示该表单,并且出现此错误
No component factory found for EmailInstructorsComponent. Did you add it to @NgModule.entryComponents?
我正在使用惰性装载,并且大多数模块已添加到shared.module文件的声明中,以避免在生产过程中出错。
我也尝试查看stackoverflow上可用的其他链接,但是它们都没有引用modal-windows / dialogs,这就是为什么我必须创建此单独的线程
classes-and-students.module.ts文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 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文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | @Component({ selector: 'ngx-instructorbidding', templateUrl: 'instructorbidding.component.html', styleUrls: ['instructorbidding.component.scss'] }) export class InstructorbiddingComponent { @ViewChild('contentTemplate', { static: true }) contentTemplate: TemplateRef; @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文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | @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文件
1 2 3 4 5 6 7 | <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> |
我不确定我犯了什么错误,因此请指出我的错误来帮助我
尝试像这样更改您的代码,以查看其是否有效
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 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 { } |