Problem Statement
How do you access RouterState and why might you need it?
Explanation
RouterState represents the tree of activated routes. You can traverse from the root to read params, data, and URL segments across nested levels—useful for breadcrumbs, analytics, and cross-feature context.
Code Solution
SolutionRead Only
constructor(router: Router){
const root = router.routerState.root;
const firstChild = root.firstChild;
// walk the tree to build breadcrumbs
}