cipchk / ngx-bootstrap-modal

simplify the work with bootstrap modal dialogs
https://cipchk.github.io/ngx-bootstrap-modal
MIT License
22 stars 7 forks source link

Angular5 打开自定义组件的问题 #9

Closed kerrph closed 6 years ago

kerrph commented 6 years ago

https://stackblitz.com/edit/ngx-bootstrap-modal-1bkq49 之前和你说的那个Angular5问题, 我再现出来了,你看一下。

cipchk commented 6 years ago

能否提供一个简约的版本,且描述重现的操作步骤。

kerrph commented 6 years ago

已简约,自定义组件在路由的环境下出错。

cipchk commented 6 years ago

?????

kerrph commented 6 years ago

1.打开此链接 https://ngx-bootstrap-modal-1bkq49.stackblitz.io/#/demo

  1. f12 打开控制台 点击自定义组件的任意按钮,无法弹框,控制台显示错误信息 snipaste_20180116_155426

这个demo 展示的内容是你的github上的demo,只不过修改了自定义组建打开的环境,是嵌套了路由

cipchk commented 6 years ago

这个问题是由于 Angular 的模块生命周期引起的,这的确是一个问题,目前你能解决的办法是在子模块加上:

 BootstrapModalModule.forRoot({ container: document.body })

或者 entryComponents 的注册放在根目录,我会增加一个 BootstrapModalModule.forChild() 解决这一问题。

kerrph commented 6 years ago

我试了一下加在子模块里面,正常弹框了。原来我是加在了app.module里面,结果一直卡在那个问题上,现在知道原因了。 非常感谢