I have an app whose components are structured as below:
1. Fam.Component
1.1. Header.Component <------ Unable access param from here
1.2. ParentGrid.Component
1.2.1. ChildGrid.Component
1.2.1.1 GrandChildGrid.Component <----- Can access from here!!
Clicking on an item in the parent grid, will load the child grid relevant to that item.
At the grand child level, my browser URL looks something like this:
http://onebigfamily.com/Fam/Parents/1/Children/23/GrandChildren
this will basically show all the grandchildren for the 23rd Child of the 1st parent.
the path for this URL in my routing config looks is like this:
Fam/Parents/:parentId/Children/childId:/GrandChildren
I can access the childId
and parentId
param values by navigating the ActivatedRoute
from my GrandChildren
component by doing a simple this.route.snapshot.params['childId']
(of course for parent ID have to traverse up the route tree).
Now to the question...
How can I access the :childId
and :parentId
from my Header Component? these values are showing up as undefined when i do a this.route.snapshot.params['childId']
?
I just need to access the parent ID and the child ID as long as they are in the URL, regardless of which component has the control.