Angular 9 References/ Router
References

ActivatedRoute

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

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

children#

get children(): ActivatedRoute[]
The children of this route in the router state tree.

component#

component: Type<any> | string | null
The component of the route.

data#

data: Observable<Data>
An observable of the static and resolved data of this route.

firstChild#

get firstChild(): ActivatedRoute|null
The first child of this route in the router state tree.

fragment#

fragment: Observable<string>
An observable of the URL fragment shared by all the routes.

outlet#

outlet: string
The outlet name of the route.

paramMap#

get paramMap(): Observable<ParamMap>
TODO

params#

params: Observable<Params>
An observable of the matrix parameters scoped to this route.

parent#

get parent(): ActivatedRoute|null
The parent of this route in the router state tree.

pathFromRoot#

get pathFromRoot(): ActivatedRoute[]
The path from the root of the router state tree to this route.

queryParamMap#

get queryParamMap(): Observable<ParamMap>
TODO

queryParams#

queryParams: Observable<Params>
An observable of the query parameters shared by all the routes.

root#

get root(): ActivatedRoute
The root of the router state.

routeConfig#

get routeConfig(): Route|null
The configuration used to match this route.

snapshot#

snapshot: ActivatedRouteSnapshot
The current snapshot of this route.

toString#

toString(): string

url#

url: Observable<UrlSegment[]>
An observable of the URL segments matched by this route.