I'm desperately trying to get the route params from a service so when I access a section from the url, I can detect the section's id and load it in this service.
The route path is 'sections/:section' with children. This gives a URL like this: /sections/2/home
I tried to use the following:
this.route.paramMap.subscribe(params => {params.get('section');});
But it returns "null"...
I also tried other options but it returned an empty string :/
Any ideas? Thanks for your time!
ActivatedRoute
object is heirarchical, it is tough to get what you are looking for from a service. If you look at yourthis.route
, you will notice that it has children routes. What you are looking for is buried in the children routes somewhere. You have to look through that tree to find it. It is confusing and really drives me crazy. Sorry you are being frustrated by this. It frustrates a lot of people, FYI. – frosty