Angular 2 modals shared between components

假装没事ソ 提交于 2019-11-29 17:01:32
eko

That plunker's original version is my question actually: How to dynamically create bootstrap modals as Angular2 components?

@Günter made an amazing answer which I think is really underrated.

The plunker has a small mistake, you can find the fixed version here: https://plnkr.co/edit/oMCZIJq58WdLgYf2D0Di?p=preview

The if cases are referencing the wrong field, so change

if(this.cmp) {
    this.cmp.destroy();
}

with

if(this.cmpRef) {
    this.cmpRef.destroy();
}

I know this topic is 6 months old, but it was a really deal for me to achieve a such thing.

So I made a npm module to allow modal sharing between components with shared data and remote opening / closing / events.

Feel free to check it out : https://github.com/biig-io/ngx-smart-modal.

The demo is here : https://biig-io.github.io/ngx-smart-modal/

Compatible with Angular >=2.0.0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!