【问题标题】:Is there any way to send the event between the service and component in angular2有没有办法在angular2中的服务和组件之间发送事件
【发布时间】:2017-02-24 16:01:52
【问题描述】:

我将 angular2-modal 用于模态警报。我只想从模态中获取确认事件。我怎样才能得到它?

【问题讨论】:

  • 有很多方法可以做到这一点。你试过搜索它吗?如果您提供有关您的问题的更多背景信息也会很棒
  • 我正在使用 shlomiassaf/angular2-modal。这是链接您可以查看此 plnkr。在 plukr 中,您可以看到 custom-modal-sample.ts 文件。请看这个函数,onKeyUp(value)。在此函数中,如果用户输入 5,则模态框将关闭。我想在 app.component.ts 中获取事件。清理有用吗?
  • 这很有帮助。能否在custom-modal-sample.ts中添加关闭按钮并通过点击app.component.ts中的按钮获取事件?
  • @yurzui,我只想知道app.component,ts中点击了哪个按钮。有什么办法吗?

标签: angular angular2-modal


【解决方案1】:

我可以根据@yurzui 的回答来实现这一点。 当我们关闭modal时,我们使用这个函数,

this.dialog.close();

如果我们使用带参数的函数,那么我们可以得到点击哪个按钮的结果。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-13
    • 1970-01-01
    • 2018-02-14
    • 1970-01-01
    • 2018-09-01
    • 2022-01-22
    • 1970-01-01
    • 2020-08-01
    相关资源
    最近更新 更多