RouterStateSnapshot

Stable

Interface

What it does

Represents the state of the router at a moment in time.

How to use

  1. @Component({templateUrl:'template.html'})
  2. class MyComponent {
  3. constructor(router: Router) {
  4. const state: RouterState = router.routerState;
  5. const snapshot: RouterStateSnapshot = state.snapshot;
  6. const root: ActivatedRouteSnapshot = snapshot.root;
  7. const child = root.firstChild;
  8. const id: Observable<string> = child.params.map(p => p.id);
  9. //...
  10. }
  11. }

Interface Overview

interface RouterStateSnapshot extends Tree {
url : string
toString() : string

}

Interface Description

Interface Details

exported from @angular/router/index, defined in @angular/router/src/router_state.ts