小编Pol*_*ris的帖子

模块中的EntryComponents用于LazyLoading

我想从组件加载模态.在Angular Material文档中写入以在entryComponents中添加模态组件:

这个 :

@NgModule({
  imports: [
    CommonModule,
    AidesRoutingModule
  ],
  declarations: [TypesAidesComponent, TypesAidesAjouterComponent],
  entryComponents : [TypesAidesAjouterComponent]
})
export class AidesModule {

}
Run Code Online (Sandbox Code Playgroud)

在TypesAidesComponent中,我想要使用TypesAidesAjouterComponent打开对话框:

let dialog = this.dialog.open(TypesAidesAjouterComponent);
    dialog.afterClosed().subscribe(res => {
      if(res){
        this.collection.addItem(res);
      }
    });
Run Code Online (Sandbox Code Playgroud)

我在一个组件延迟加载:

{
        path: 'types-aides',
        loadChildren: 'app/modules/aides/aides.module#AidesModule'
    },
Run Code Online (Sandbox Code Playgroud)

但我有这个错误:

错误:找不到TypesAidesAjouterComponent的组件工厂.你有没有把它添加到@ NgModule.entryComponents?

我找到了一个解决方案,它是移动删除LazyLoading,但我的应用程序很大,不可能.

你有什么建议吗 ?

angular angular5

13
推荐指数
1
解决办法
5134
查看次数

标签 统计

angular ×1

angular5 ×1