Angular 2 - 尝试导入组件时出错

Angular 2 - Error when try to import a component

我有一个具有这种结构的项目:

app
|
 |pages
    |Dashboard
        |Component1
    |UI
        |ModalComponent

我想在 /Dashboard/Component1 上显示一个 ModalComponent,但是当我尝试它时出现了这个错误:

No component factory found for DefaultModal. Did you add it to @NgModule.entryComponents?

我的dashboard.module.ts

import { PieChartService } from './pieChart/pieChart.service';

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    AppTranslationModule,
    NgaModule,
    routing
  ],
  declarations: [
     PieChart,
     /..Some components../

],
  providers: [
    PieChartService,
    /..Some services../
  ]

})
export class DashboardModule {}

我的modal.module.ts

import { NgModule }      from '@angular/core';
import { CommonModule }  from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgbDropdownModule, NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { DefaultModal } from './components/modals/default-modal.component';


    @NgModule({
  imports: [
    CommonModule,
    FormsModule,
    /.../
  ],
  declarations: [
    DefaultModal
  ],
  exports: [
    DefaultModal
  ]
})
export class UiModule {
}

我做错了什么?谢谢

编辑

如果我在 DashboardModule 中添加 entryComponents: [DefaultModal],错误将更改为:

Component DefaultModal is not part of any NgModule or the module has not been imported into your module.

感谢@echonax

我必须像这样更改我的主要模块:

dashboard.module.ts

import { PieChartService } from './pieChart/pieChart.service';
import { UiModule } from './ui/ui.module'; //<====this line

@NgModule({
      imports: [
        CommonModule,
        FormsModule,
        AppTranslationModule,
        NgaModule,
        UiModule, //<====this line
        routing
      ],
      declarations: [
         PieChart,
     /..Some components../

],
  providers: [
    PieChartService,
    /..Some services../
  ]

})
export class DashboardModule {}

我发现这些模块的工作方式与 "packages" 相同,而且如果您在一个模块中声明了多个组件,那么在导入该模块时您会带来所有这些组件的声明,无需任何组件即可使用它们问题。