Chapter 6. Router State

Router State

During a navigation, after redirects have been applied, the router creates a RouterStateSnapshot .

What is RouterStateSnapshot?

interface RouterStateSnapshot {
  root: ActivatedRouteSnapshot;
}

interface ActivatedRouteSnapshot {
  url: UrlSegment[];
  params: {[name:string]:string};
  data: {[name:string]:any};

  queryParams: {[name:string]:string};
  fragment: string;

  root: ActivatedRouteSnapshot;
  parent: ActivatedRouteSnapshot;
  firstchild: ActivatedRouteSnapshot;
  children: ActivatedRouteSnapshot[];
}

As you can see RouterStateSnapshot is a tree of activated route snapshots. Every node in this tree knows about the "consumed" URL segments, ...

Get Angular Router now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.