angular - How can I get a parameter from the URL in my components constructor using ActivatedRoute -
i in constructor:
this.articleslug = _route.url._value[1].path;
but typescript doesn't it:
property: "_value" not exist on type observable<params>
is there cleaner way? i'm using angular 4 typescript , webpack.
this when use: _route: activatedroute in contructor.
you need subscribe on route , extract callback function. like:
_route.url.subscribe(values: urlsegment[] -> /* url segments available in values array */) // or if need url parameters _route.params.subscribe(params: params -> console.log(params['paramname']));
Comments
Post a Comment