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.
包含与当前组件相关的路由信息。ActivatedRoute
也可用于遍历路由器的状态树。
说明 @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); } } 属性 属性名 类型 说明 snapshotActivatedRouteSnapshot
The current snapshot of this route
本路由此刻的快照
urlObservable<UrlSegment []>
An observable of the URL segments matched by this route
一个 Observable
,表示与当前路由匹配的 URL 段
paramsObservable<Params >
An observable of the matrix parameters scoped to this route
一个 Observable
,表示当前路由范围内的矩阵参数(;
)
queryParamsObservable<Params >
An observable of the query parameters shared by all the routes
一个 Observable
,表示所有路由共享的查询参数(?
)
fragmentObservable<string>
An observable of the URL fragment shared by all the routes
一个 Observable
,表示由所有路由共享的 URL 片段(#
)
dataObservable<Data >
An observable of the static and resolved data of this route.
一个 Observable
,表示该路由的静态数据和解析出的数据。
outletstring
The outlet name of the route. It's a constant
本路由对应的出口名,是个常量
componentType <any> | string | null
The component of the route. It's a constant
本路由对应的组件,是个常量
routeConfigRoute | null
只读 The configuration used to match this route
用于匹配本路由的配置项
rootActivatedRoute
只读 The root of the router state
路由器状态树的根节点
parentActivatedRoute | null
只读 The parent of this route in the router state tree
在路由器状态树中,当前路由的父路由
firstChildActivatedRoute | null
只读 The first child of this route in the router state tree
在路由器状态树中,当前路由的第一个子路由
childrenActivatedRoute []
只读 The children of this route in the router state tree
在路由器状态树中,当前路由的所有子路由
pathFromRootActivatedRoute []
只读 The path from the root of the router state tree to this route
在路由器状态树中从根节点开始到当前路由的完整路径
paramMapObservable<ParamMap >
只读 queryParamMapObservable<ParamMap >
只读
方法 toString(): string 参数 没有参数。
返回值 string