【问题标题】:No component factory found for EmailInstructorsComponent. Did you add it to @NgModule.entryComponents?未找到 EmailInstructorsComponent 的组件工厂。你把它添加到@NgModule.entryComponents 了吗?
【发布时间】: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>

我不确定我犯了什么错误,所以请指出我的错误来帮助我

【问题讨论】:

标签: node.js angular typescript ecmascript-6 single-page-application


【解决方案1】:

尝试像这样更改您的代码,看看它是否有效

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 { }

【讨论】:

    猜你喜欢
    • 2018-01-06
    • 2019-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-25
    • 2018-05-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多