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 books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.