InterviewHubPRO
Section Overview
Q69

Question 69 of 283

Part 3: Angular Router, Navigation & SSR Universal (63 - 75)

24%
Angular & Signals (283 Qs)•Part 3: Angular Router, Navigation & SSR Universal (63 - 75)

What is router state?

RouterState is a tree of activated routes. Every node in this tree knows about the "consumed" URL segments, the extracted parameters, and the resolved data. You can access the current RouterState from anywhere in the application using the Router service and the routerState property.

javascript
@Component({templateUrl:'template.html'})
class MyComponent {
constructor(router: Router) {
 const state: RouterState = router.routerState;
 const root: ActivatedRoute = state.root;
 const child = root.firstChild;
 const id: Observable<string> = child.params.map(p => p.id);
 //...
}
}