【问题标题】:angular 2 trigger a modal open outside of router moduleangular 2 触发在路由器模块外部打开的模态
【发布时间】:2017-05-05 05:18:51
【问题描述】:

我想通过单击路由器插座内组件模板中的按钮来触发路由器插座外组件模板中 div 的隐藏/显示:

应用组件

`<div class="content col-md-10 container-fluid">   
    <company-add-form></company-add-form>
    <router-outlet></router-outlet>
</div>`

公司添加表单组件

`<div>
    <p>Make me showwwww</p>
    <button class="btn">Close</button>
</div>`

公司页面组件(将在路由器出口中呈现)

`<div>
    <button class="btn">Open company add form</button>
</div>`

想法

  • 通常存在相当一致的父子关系,但由于路由器出口位于两者之间,因此您不能只使用 ViewChild。

【问题讨论】:

    标签: angular angular2-routing


    【解决方案1】:

    不能绑定路由器添加的组件。

    您应该使用共享服务@angular/injectable 查看component communication,例如@angular cookbook

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-04
      • 1970-01-01
      • 2017-04-11
      • 1970-01-01
      • 1970-01-01
      • 2016-12-28
      • 2020-05-24
      • 1970-01-01
      相关资源
      最近更新 更多