NG-ZORRO / ng-zorro-antd

Angular UI Component Library based on Ant Design
https://ng.ant.design
MIT License
8.85k stars 3.91k forks source link

entryComponents in lazy loaded module not work when use custorm modal #507

Closed yushaoyi closed 6 years ago

yushaoyi commented 6 years ago

在懒加载模块中使用modal打开自定义component,将component放在当前模块的entryComponents中

报错
No component factory found for EditStudentComponet. Did you add it to @NgModule.entryComponents?

网上比较多的问题,将自定义component放在appModule不推荐这样做,麻烦问下有比较好的解决方法没

cipchk commented 6 years ago

@yushaoyi 可以明确一点懒加载并不会存在该问题。你需要提供更多的细节,包括如果调用、懒加载等信息,才可以帮你分析问题根源;当然最好是在 plnkr 中复现。

yushaoyi commented 6 years ago

@cipchk,谢谢关注,我也有学习你的项目代码结构,你的项目的确可以正常调用自定义modal。我目前在做的简单架子在https://github.com/yushaoyi/angular-template,会出现这个问题,可以麻烦有时间帮忙看下,使用modal弹框的路由在http://localhost:4200/workspace/student/baseInfo

cipchk commented 6 years ago

我想应该是多重惰性模块加载导致的,其实 workspace 只是一个用于布局的组件,你大可这么用:

{
    path: 'workspace',
    component: WorkspaceComponent,
    children: [
        { path: 'student', component: xxxxx }
    ]
}

PS:非ng-zorro-antd的问题,我建议不要在这里提问,因为我们每一条记录都会导致117个人产生一个提醒。

yushaoyi commented 6 years ago

好的,发现问题了。ng-alain 里面是把modal.helper这个调用modal的service工具类放在了sharedModule的provider里,所以懒加载模块不会出现这个问题。这是Angular的问题


Angular:但在sharedModule提供其他的service需要慎重,当前modal.helper单纯提供了调用modal,所以我觉得应该不会出现其他问题,Angular文档建议全局共享的service放在coreModule里

lock[bot] commented 5 years ago

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.