feat(router): add enableTracing option

This commit is contained in:
vsavkin 2016-06-09 14:32:03 -07:00
parent 777eb2f159
commit 9de56481f1
4 changed files with 25 additions and 3 deletions

View File

@ -6,6 +6,7 @@ export {CanActivate, CanDeactivate} from './interfaces';
export {Event, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, RoutesRecognized, Router} from './router';
export {RouterOutletMap} from './router_outlet_map';
export {provideRouter} from './router_providers';
export {ExtraOptions} from './common_router_providers';
export {ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot} from './router_state';
export {PRIMARY_OUTLET, Params} from './shared';
export {DefaultUrlSerializer, UrlSerializer} from './url_serializer';

View File

@ -40,6 +40,10 @@ export interface NavigationExtras {
*/
export class NavigationStart {
constructor(public id: number, public url: UrlTree) {}
toString(): string {
return `NavigationStart(id: ${this.id}, url: '${this.url}')`;
}
}
/**
@ -47,6 +51,10 @@ export class NavigationStart {
*/
export class NavigationEnd {
constructor(public id: number, public url: UrlTree) {}
toString(): string {
return `NavigationEnd(id: ${this.id}, url: '${this.url}')`;
}
}
/**
@ -54,6 +62,10 @@ export class NavigationEnd {
*/
export class NavigationCancel {
constructor(public id: number, public url: UrlTree) {}
toString(): string {
return `NavigationCancel(id: ${this.id}, url: '${this.url}')`;
}
}
/**
@ -61,6 +73,10 @@ export class NavigationCancel {
*/
export class NavigationError {
constructor(public id: number, public url: UrlTree, public error: any) {}
toString(): string {
return `NavigationError(id: ${this.id}, url: '${this.url}', error: ${this.error})`;
}
}
/**
@ -68,6 +84,10 @@ export class NavigationError {
*/
export class RoutesRecognized {
constructor(public id: number, public url: UrlTree, public urlAfterRedirects: UrlTree, public state: RouterStateSnapshot) {}
toString(): string {
return `RoutesRecognized(id: ${this.id}, url: '${this.url}', urlAfterRedirects: '${this.urlAfterRedirects}', state: ${this.state})`;
}
}
export type Event = NavigationStart | NavigationEnd | NavigationCancel | NavigationError;
@ -88,7 +108,7 @@ export class Router {
constructor(
private rootComponentType: Type, private resolver: ComponentResolver,
private urlSerializer: UrlSerializer, private outletMap: RouterOutletMap,
private location: Location, private injector: Injector, private config: RouterConfig) {
private location: Location, private injector:g Injector, private config: RouterConfig) {
this.routerEvents = new Subject<Event>();
this.currentUrlTree = createEmptyUrlTree();
this.currentRouterState = createEmptyState(this.rootComponentType);

View File

@ -23,8 +23,8 @@ import {RouterConfig} from './config';
* bootstrap(AppCmp, [provideRouter(router)]);
* ```
*/
export function provideRouter(config: RouterConfig): any[] {
export function provideRouter(config: RouterConfig, opts: common.ExtraOptions = {}): any[] {
return [
{provide: PlatformLocation, useClass: BrowserPlatformLocation}, ...common.provideRouter(config)
{provide: PlatformLocation, useClass: BrowserPlatformLocation}, ...common.provideRouter(config, opts)
];
}

View File

@ -27,6 +27,7 @@
"src/url_serializer.ts",
"src/url_tree.ts",
"src/shared.ts",
"src/common_router_providers.ts",
"src/router_providers.ts",
"src/create_url_tree.ts",
"src/directives/router_outlet.ts",