Help Angular by taking a 1 minute survey!Go to surveyHome

ActivatedRouteSnapshot

Contains the information about a route associated with a component loaded in an outlet at a particular moment in time. ActivatedRouteSnapshot can also be used to traverse the router state tree.

See more...

      
      
  1. interface ActivatedRouteSnapshot {
  2. routeConfig: Route | null
  3. url: UrlSegment[]
  4. params: Params
  5. queryParams: Params
  6. fragment: string
  7. data: Data
  8. outlet: string
  9. component: Type<any> | string | null
  10. root: ActivatedRouteSnapshot
  11. parent: ActivatedRouteSnapshot | null
  12. firstChild: ActivatedRouteSnapshot | null
  13. children: ActivatedRouteSnapshot[]
  14. pathFromRoot: ActivatedRouteSnapshot[]
  15. paramMap: ParamMap
  16. queryParamMap: ParamMap
  17. toString(): string
  18. }

Description

@Component({templateUrl:'./my-component.html'}) class MyComponent { constructor(route: ActivatedRoute) { const id: string = route.snapshot.params.id; const url: string = route.snapshot.url.join(''); const user = route.snapshot.data.user; } }
      
      @Component({templateUrl:'./my-component.html'})
class MyComponent {
  constructor(route: ActivatedRoute) {
    const id: string = route.snapshot.params.id;
    const url: string = route.snapshot.url.join('');
    const user = route.snapshot.data.user;
  }
}
    

Properties

Property Description
routeConfig: Route | null Read-only.

The configuration used to match this route *

url: UrlSegment[]

The URL segments matched by this route

params: Params

The matrix parameters scoped to this route

queryParams: Params

The query parameters shared by all the routes

fragment: string

The URL fragment shared by all the routes

data: Data

The static and resolved data of this route

outlet: string

The outlet name of the route

component: Type<any> | string | null

The component of the route

root: ActivatedRouteSnapshot Read-only.

The root of the router state

parent: ActivatedRouteSnapshot | null Read-only.

The parent of this route in the router state tree

firstChild: ActivatedRouteSnapshot | null Read-only.

The first child of this route in the router state tree

children: ActivatedRouteSnapshot[] Read-only.

The children of this route in the router state tree

pathFromRoot: ActivatedRouteSnapshot[] Read-only.

The path from the root of the router state tree to this route

paramMap: ParamMap Read-only.
queryParamMap: ParamMap Read-only.

Methods

toString(): string
      
      toString(): string
    
Parameters

There are no parameters.

Returns

string