From 9de56481f156c5edce2f2f0c24a3075d66905746 Mon Sep 17 00:00:00 2001 From: vsavkin Date: Thu, 9 Jun 2016 14:32:03 -0700 Subject: [PATCH] feat(router): add enableTracing option --- modules/@angular/router/src/index.ts | 1 + modules/@angular/router/src/router.ts | 22 ++++++++++++++++++- .../@angular/router/src/router_providers.ts | 4 ++-- modules/@angular/router/tsconfig.json | 1 + 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/modules/@angular/router/src/index.ts b/modules/@angular/router/src/index.ts index 24e70a2352..7c053bf66f 100644 --- a/modules/@angular/router/src/index.ts +++ b/modules/@angular/router/src/index.ts @@ -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'; diff --git a/modules/@angular/router/src/router.ts b/modules/@angular/router/src/router.ts index ad87fec116..e859e81f81 100644 --- a/modules/@angular/router/src/router.ts +++ b/modules/@angular/router/src/router.ts @@ -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(); this.currentUrlTree = createEmptyUrlTree(); this.currentRouterState = createEmptyState(this.rootComponentType); diff --git a/modules/@angular/router/src/router_providers.ts b/modules/@angular/router/src/router_providers.ts index 3be515db05..4c0b7d9426 100644 --- a/modules/@angular/router/src/router_providers.ts +++ b/modules/@angular/router/src/router_providers.ts @@ -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) ]; } diff --git a/modules/@angular/router/tsconfig.json b/modules/@angular/router/tsconfig.json index 945409c60c..b74088bc2e 100644 --- a/modules/@angular/router/tsconfig.json +++ b/modules/@angular/router/tsconfig.json @@ -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",