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

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -