【发布时间】:2019-12-06 13:41:13
【问题描述】:
我正在使用 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>
我不确定我犯了什么错误,所以请指出我的错误来帮助我
【问题讨论】:
-
您能否参考上面的链接,看看是否有任何答案可以解决您的问题。
-
@NicholasK 我已经看到了这个链接,但它并没有解决我的问题,所以我为自己的代码创建了一个单独的线程
标签: node.js angular typescript ecmascript-6 single-page-application