RouterState

Stable Interface

What it does

Represents the state of the router.

How to use

@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);
    //...
  }
}

Interface Overview

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

Interface Description

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.

See ActivatedRoute for more information.

Interface Details

snapshot : RouterStateSnapshot

The current snapshot of the router state.

toString() : string

exported from @angular/router/index, defined in @angular/router/src/router_state.ts

doc_Angular
2016-10-06 09:46:58
Comments
Leave a Comment

Please login to continue.