RouterState
interface
Represents the state of the router as a tree of activated routes.
interface RouterState extends Tree { snapshot: RouterStateSnapshot toString(): string }
See also
Properties
Property | Description |
---|---|
snapshot: RouterStateSnapshot | The current snapshot of the router state |
Methods
toString() |
---|
|
Usage notes
Every node in the route tree is an ActivatedRoute
instance that knows about the "consumed" URL segments, the extracted parameters, and the resolved data. Use the ActivatedRoute
properties to traverse the tree from any node.
Example
@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); //... } }
© 2010–2020 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v8.angular.io/api/router/RouterState