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, the extracted parameters, and the resolved data. To make it clearer, let's look at this example:
[ { path: ':folder', children: [ { path: '', component: ConversationsCmp }, { path: ':id', component: ConversationCmp, children: [ ...