Angular 2 new Router: How to get router parameters of a child component?

后端 未结 6 2069
伪装坚强ぢ
伪装坚强ぢ 2021-01-01 19:53

In the latest version of @angular/router 3.0.0-rc.1 The way you get the parameters from a URL/route changed.

Based on this documentation yo

6条回答
  •  無奈伤痛
    2021-01-01 20:17

    The ActivatedRoute has getters to access its parent/child route information.

    In order to access the first child route from the parent, you would use:

    this.route.firstChild.params

    If you wanted all the child routes you would use the children property. This returns an array of ActivatedRoute

    this.route.children

    If you were in a child route and needed parameters from the parent:

    this.route.parent.params

提交回复
热议问题