【问题标题】:subscribe to changes from modal component in ngx-bootstrap modal订阅 ngx-bootstrap 模态中模态组件的更改
【发布时间】:2018-03-14 17:54:15
【问题描述】:

我通过this.modalService.show(ListModalComponent, <options>) 使用ngx-bootstrap 启动一个模态,将组件传递给模态(docs link)。我需要订阅组件中的事件发射器以对模态内部的更改事件采取行动,但我无法获得对组件的引用,因为它在显示模态之前不存在。推荐的方法是什么?

这是一个带有my current setup 的 Plunkr。请参阅app.component.ts 第 17 行。

【问题讨论】:

    标签: angular ngx-bootstrap ngx-bootstrap-modal


    【解决方案1】:

    您可以像这样this.bsModalRef.content.listUpdates.subscribe({...}).show() 后订阅此活动

    另外,您可以创建一个共享服务并将其注入到两个组件中,并使用此事件而不是模态的内部事件。

    【讨论】:

    • 谢谢!我没有意识到我可以访问content
    • this.bsModalRef.content.updateFunction.subcribe 不是函数......我在 this.bsModalRef.content 中控制台内容(我发现有 updateFuntion)......我正在使用 Angular 9.1 .3.......我在子组件中正确设置了 output() 属性
    猜你喜欢
    • 1970-01-01
    • 2018-08-22
    • 1970-01-01
    • 2020-10-14
    • 1970-01-01
    • 2018-04-04
    • 1970-01-01
    • 2015-11-17
    • 1970-01-01
    相关资源
    最近更新 更多