ActivatedRoute

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

Contains the information about a route associated with a component loaded in an outlet. An ActivatedRoute can also be used to traverse the router state tree.

Example

@Component({...})
class MyComponent {
  constructor(route: ActivatedRoute) {
    const id: Observable<string> = route.params.map(p => p.id);
    const url: Observable<string> = route.url.map(segments => segments.join(''));
    // route.data includes both `data` and `resolve`
    const user = route.data.map(d => d.user);
  }
}
Links & Tutorials

Properties

snapshot#

snapshot: ActivatedRouteSnapshot

The current snapshot of this route.

url#

url: Observable<UrlSegment[]>

An observable of the URL segments matched by this route.

params#

params: Observable<Params>

An observable of the matrix parameters scoped to this route.

queryParams#

queryParams: Observable<Params>

An observable of the query parameters shared by all the routes.

fragment#

fragment: Observable<string>

An observable of the URL fragment shared by all the routes.

data#

data: Observable<Data>

An observable of the static and resolved data of this route.

outlet#

outlet: string

The outlet name of the route.

component#

component: Type<any> | string | null

The component of the route.

routeConfig#

routeConfig: Route | null

The configuration used to match this route.

root#

root: ActivatedRoute

The root of the router state.

parent#

parent: ActivatedRoute | null

The parent of this route in the router state tree.

firstChild#

firstChild: ActivatedRoute | null

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

children#

children: ActivatedRoute[]

The children of this route in the router state tree.

pathFromRoot#

pathFromRoot: ActivatedRoute[]

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

paramMap#

paramMap: Observable<ParamMap>

TODO

queryParamMap#

queryParamMap: Observable<ParamMap>

TODO