【问题标题】:Is it possible to get a primary route-outlet param in a secondary outlet Angular 2?是否可以在辅助出口 Angular 2 中获得主要路由出口参数?
【发布时间】:2018-01-23 18:32:33
【问题描述】:

我一直在尝试使用路由 ActivatedRoute 模块从命名路由获取辅助路由出口。例如

当前网址:http://localhost:4200/dashboard/contraceptives/(assessment:5991780301d88a211e86e012//details:599062793f86454d43896255)

分店:

<div class="col m4 z-depth-3">
     <router-outlet name="details"></router-outlet>
 </div>
 <div class="col m4 z-depth-3">
     <router-outlet name="assessment"></router-outlet>
 </div>

组件:

如何获取当前插座和组件中的详细信息参数?

 ngOnInit() {
    this.sub = this.route.params.subscribe(params => {
      this.id = params['id'];
    });
  }

【问题讨论】:

标签: angular angular2-routing


【解决方案1】:

我设法找到了一条路:

constructor(router:Router){
    RouterLinks.events(event=>{
        // here i am subscribing to the events
        const primaryRouter = event.state.root.firstChild;
        // where first child is the primary router-outlet
    })
}

【讨论】:

  • 欢迎来到SO,请解释你的答案。不要只发布代码sn-ps
猜你喜欢
  • 2017-02-10
  • 1970-01-01
  • 2019-06-04
  • 2019-09-29
  • 2023-03-15
  • 1970-01-01
  • 1970-01-01
  • 2017-12-23
  • 1970-01-01
相关资源
最近更新 更多