RouterState

Represents the state of the router.

interface RouterState extends Tree{ snapshot: RouterStateSnapshot toString(): string }

说明

RouterState is a tree of activated routes. Every node in this tree knows about the "consumed" URL segments, the extracted parameters, and the resolved data.

Example

@Component({templateUrl:'template.html'}) class MyComponent { constructor(router: Router) { const state: RouterState = router.routerState; const root: ActivatedRoute = state.root; const child = root.firstChild; const id: Observable<string> = child.params.map(p => p.id); //... } }

See ActivatedRoute for more information.

属性

属性名类型说明
snapshot

The current snapshot of the router state

方法

toString(): string

参数

没有参数。

返回值

string