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.
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;
}
}
Properties
children
#
get children(): ActivatedRouteSnapshot[]
The children of this route in the router state tree
component
#
component: Type<any> | string | null
The component of the route.
data
#
data: Data
The static and resolved data of this route.
firstChild
#
get firstChild(): ActivatedRouteSnapshot|null
The first child of this route in the router state tree
fragment
#
fragment: string
The URL fragment shared by all the routes.
outlet
#
outlet: string
The outlet name of the route.
paramMap
#
get paramMap(): ParamMap
params
#
params: Params
The matrix parameters scoped to this route.
parent
#
get parent(): ActivatedRouteSnapshot|null
The parent of this route in the router state tree
pathFromRoot
#
get pathFromRoot(): ActivatedRouteSnapshot[]
The path from the root of the router state tree to this route
queryParamMap
#
get queryParamMap(): ParamMap
queryParams
#
queryParams: Params
The query parameters shared by all the routes.
root
#
get root(): ActivatedRouteSnapshot
The root of the router state
routeConfig
#
routeConfig: Route|null
The configuration used to match this route *
toString
#
toString(): string
url
#
url: UrlSegment[]
The URL segments matched by this route.