Closed yushaoyi closed 6 years ago
@yushaoyi 可以明确一点懒加载并不会存在该问题。你需要提供更多的细节,包括如果调用、懒加载等信息,才可以帮你分析问题根源;当然最好是在 plnkr 中复现。
@cipchk,谢谢关注,我也有学习你的项目代码结构,你的项目的确可以正常调用自定义modal。我目前在做的简单架子在https://github.com/yushaoyi/angular-template,会出现这个问题,可以麻烦有时间帮忙看下,使用modal弹框的路由在http://localhost:4200/workspace/student/baseInfo
我想应该是多重惰性模块加载导致的,其实 workspace
只是一个用于布局的组件,你大可这么用:
{
path: 'workspace',
component: WorkspaceComponent,
children: [
{ path: 'student', component: xxxxx }
]
}
PS:非ng-zorro-antd的问题,我建议不要在这里提问,因为我们每一条记录都会导致117个人产生一个提醒。
好的,发现问题了。ng-alain 里面是把modal.helper这个调用modal的service工具类放在了sharedModule的provider里,所以懒加载模块不会出现这个问题。这是Angular的问题
Angular:但在sharedModule提供其他的service需要慎重,当前modal.helper单纯提供了调用modal,所以我觉得应该不会出现其他问题,Angular文档建议全局共享的service放在coreModule里
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.
在懒加载模块中使用modal打开自定义component,将component放在当前模块的entryComponents中
网上比较多的问题,将自定义component放在appModule不推荐这样做,麻烦问下有比较好的解决方法没