【问题标题】:No component factory found for 'CreatePrefixComponent'未找到“CreatePrefixComponent”的组件工厂
【发布时间】:2019-03-13 19:22:46
【问题描述】:

我添加了一个子组件 (CreatePrefixComponent),用于在单击按钮时显示弹出模式。我收到以下错误:

Error: No component factory found for CreatePrefixComponent. Did you add it to @NgModule.entryComponents?

但是我在子组件的模块中添加了CreatePrefixComponent,像这样:

import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MaterialModule } from '../../material.module';
import { PrefixComponent } from './prefix.component';
import { RouterModule } from '@angular/router';
import { prefixRoutes } from './prefix.routing';
import { CreatePrefixComponent } from './create-prefix/create-prefix.component';
import { MatPaginatorModule, MatTableModule } from '@angular/material';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { FlexLayoutModule } from '@angular/flex-layout';

@NgModule({
  imports: [
    CommonModule,
    MaterialModule,
    RouterModule.forChild(prefixRoutes),
    MatTableModule,
    MatPaginatorModule,
    FormsModule,
    ReactiveFormsModule,
    FlexLayoutModule,
  ],
  declarations: [PrefixComponent, CreatePrefixComponent],
  entryComponents: [CreatePrefixComponent]
})
export class PrefixModule { }

我在项目中使用了棱角材料。

有人能指出我正确的方向吗?我错过了什么吗?

【问题讨论】:

  • 发布CreatePrefixComponent

标签: angular popup angular-material angular6 angular-module


【解决方案1】:

添加 MatDialogModule 并检查一次..

【讨论】:

  • 非常感谢。我的错误是我没有在 material.module 导入中包含 MatDialogModule。完成后就修复了
猜你喜欢
  • 2020-03-08
  • 2019-03-02
  • 1970-01-01
  • 2020-07-01
  • 2019-07-10
  • 2018-01-14
  • 1970-01-01
  • 1970-01-01
  • 2018-08-07
相关资源
最近更新 更多