docs: adds missing api docs
This commit is contained in:
@ -4,10 +4,32 @@ import { Observable } from 'rxjs/Observable';
|
||||
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
|
||||
import { ComponentFactory, Type } from '@angular/core';
|
||||
|
||||
/**
|
||||
* A collection of parameters.
|
||||
*/
|
||||
export type Params = { [key: string]: string };
|
||||
|
||||
export const PRIMARY_OUTLET = "PRIMARY_OUTLET";
|
||||
/**
|
||||
* Name of the primary outlet.
|
||||
* @type {string}
|
||||
*/
|
||||
export const PRIMARY_OUTLET: string = "PRIMARY_OUTLET";
|
||||
|
||||
/**
|
||||
* The state of the router at a particular moment in time.
|
||||
*
|
||||
* ### Usage
|
||||
*
|
||||
* ```
|
||||
* class MyComponent {
|
||||
* constructor(router: Router) {
|
||||
* const state = router.routerState;
|
||||
* const id: Observable<string> = state.firstChild(state.root).params.map(p => p.id);
|
||||
* const isDebug: Observable<string> = state.queryParams.map(q => q.debug);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export class RouterState extends Tree<ActivatedRoute> {
|
||||
constructor(root: TreeNode<ActivatedRoute>, public queryParams: Observable<Params>, public fragment: Observable<string>) {
|
||||
super(root);
|
||||
@ -19,11 +41,23 @@ export function createEmptyState(rootComponent: Type): RouterState {
|
||||
const emptyParams = new BehaviorSubject({});
|
||||
const emptyQueryParams = new BehaviorSubject({});
|
||||
const fragment = new BehaviorSubject("");
|
||||
// TODO outlet name should not be outlet
|
||||
const activated = new ActivatedRoute(emptyUrl, emptyParams, PRIMARY_OUTLET, rootComponent, <any>null);
|
||||
return new RouterState(new TreeNode<ActivatedRoute>(activated, []), emptyQueryParams, fragment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Contains the information about a component loaded in an outlet.
|
||||
*
|
||||
* ### Usage
|
||||
*
|
||||
* ```
|
||||
* class MyComponent {
|
||||
* constructor(route: ActivatedRoute) {
|
||||
* const id: Observable<string> = route.params.map(p => p.id);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export class ActivatedRoute {
|
||||
constructor(public urlSegments: Observable<UrlSegment[]>,
|
||||
public params: Observable<Params>,
|
||||
|
Reference in New Issue
Block a user