ActivatedRouteSnapshot

interface

npm Package @angular/router
Module import { ActivatedRouteSnapshot } from '@angular/router';
Source router/src/router_state.ts

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.

Interface Overview

interface ActivatedRouteSnapshot { 
  get routeConfig: Route | null
  url: UrlSegment[]
  params: Params
  queryParams: Params
  fragment: string
  data: Data
  outlet: string
  component: Type<any> | string | null
  get root: ActivatedRouteSnapshot
  get parent: ActivatedRouteSnapshot | null
  get firstChild: ActivatedRouteSnapshot | null
  get children: ActivatedRouteSnapshot[]
  get pathFromRoot: ActivatedRouteSnapshot[]
  get paramMap: ParamMap
  get queryParamMap: ParamMap
  toString(): string
}

How To Use

@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;
  }
}

Members

get routeConfig: Route | null

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

get root: ActivatedRouteSnapshot

The root of the router state

get parent: ActivatedRouteSnapshot | null

The parent of this route in the router state tree

get firstChild: ActivatedRouteSnapshot | null

The first child of this route in the router state tree

get children: ActivatedRouteSnapshot[]

The children of this route in the router state tree

get pathFromRoot: ActivatedRouteSnapshot[]

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

get paramMap: ParamMap

get queryParamMap: ParamMap

toString(): string

© 2010–2018 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v5.angular.io/api/router/ActivatedRouteSnapshot