Angular2 get current route's alias

后端 未结 5 1909
情深已故
情深已故 2021-01-11 10:39

I\'m able to get current route\'s path like: /about, /, /news with location.path(). But how can I get its alias instead (the \'as\' part in the definition of a route)?

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-11 11:11

    Can't see a way of getting it, but one alternative is to use RouteData to pass the alias of the route

    https://angular.io/docs/ts/latest/api/router/RouteData-class.html

提交回复
热议问题