Angular2 (rc4) - Check active child route in parent component

前端 未结 2 1249
长情又很酷
长情又很酷 2020-12-11 10:21

I am trying to check the active child route in a parent component, but I am having difficulties with it.

I have tried to subscribe to the ActivatedRoute by doing som

2条回答
  •  星月不相逢
    2020-12-11 10:49

    You can access active child route using below code snippet

    constructor(private router:Router, private currentActivatedRoute:ActivatedRoute)
    // this should be called in ngOnInit
        var state = this.router.routerState
        var children = state.children(this.currentActivatedRoute)
    

    RouterState, Tree

提交回复
热议问题