ActivatedRouteSnapshot

This is the documentation for Angular 6.
You can switch to the latest version Angular 7.

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.

Example

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

Properties

routeConfig#

The configuration used to match this route.

routeConfig: Route | null

url#

The URL segments matched by this route.

url: UrlSegment[]

params#

The matrix parameters scoped to this route.

params: Params

queryParams#

The query parameters shared by all the routes.

queryParams: Params

fragment#

The URL fragment shared by all the routes.

fragment: string

data#

The static and resolved data of this route.

data: Data

outlet#

The outlet name of the route.

outlet: string

component#

The component of the route.

component: Type<any> | string | null

root#

The root of the router state.

root: ActivatedRouteSnapshot

parent#

The parent of this route in the router state tree.

parent: ActivatedRouteSnapshot | null

firstChild#

The first child of this route in the router state tree.

firstChild: ActivatedRouteSnapshot | null

children#

The children of this route in the router state tree.

children: ActivatedRouteSnapshot[]

pathFromRoot#

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

pathFromRoot: ActivatedRouteSnapshot[]

paramMap#

TODO

paramMap: ParamMap

queryParamMap#

TODO

queryParamMap: ParamMap