feat(router): add enableTracing option
This commit is contained in:
parent
777eb2f159
commit
9de56481f1
|
@ -6,6 +6,7 @@ export {CanActivate, CanDeactivate} from './interfaces';
|
||||||
export {Event, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, RoutesRecognized, Router} from './router';
|
export {Event, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, RoutesRecognized, Router} from './router';
|
||||||
export {RouterOutletMap} from './router_outlet_map';
|
export {RouterOutletMap} from './router_outlet_map';
|
||||||
export {provideRouter} from './router_providers';
|
export {provideRouter} from './router_providers';
|
||||||
|
export {ExtraOptions} from './common_router_providers';
|
||||||
export {ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot} from './router_state';
|
export {ActivatedRoute, ActivatedRouteSnapshot, RouterState, RouterStateSnapshot} from './router_state';
|
||||||
export {PRIMARY_OUTLET, Params} from './shared';
|
export {PRIMARY_OUTLET, Params} from './shared';
|
||||||
export {DefaultUrlSerializer, UrlSerializer} from './url_serializer';
|
export {DefaultUrlSerializer, UrlSerializer} from './url_serializer';
|
||||||
|
|
|
@ -40,6 +40,10 @@ export interface NavigationExtras {
|
||||||
*/
|
*/
|
||||||
export class NavigationStart {
|
export class NavigationStart {
|
||||||
constructor(public id: number, public url: UrlTree) {}
|
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 {
|
export class NavigationEnd {
|
||||||
constructor(public id: number, public url: UrlTree) {}
|
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 {
|
export class NavigationCancel {
|
||||||
constructor(public id: number, public url: UrlTree) {}
|
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 {
|
export class NavigationError {
|
||||||
constructor(public id: number, public url: UrlTree, public error: any) {}
|
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 {
|
export class RoutesRecognized {
|
||||||
constructor(public id: number, public url: UrlTree, public urlAfterRedirects: UrlTree, public state: RouterStateSnapshot) {}
|
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;
|
export type Event = NavigationStart | NavigationEnd | NavigationCancel | NavigationError;
|
||||||
|
@ -88,7 +108,7 @@ export class Router {
|
||||||
constructor(
|
constructor(
|
||||||
private rootComponentType: Type, private resolver: ComponentResolver,
|
private rootComponentType: Type, private resolver: ComponentResolver,
|
||||||
private urlSerializer: UrlSerializer, private outletMap: RouterOutletMap,
|
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.routerEvents = new Subject<Event>();
|
||||||
this.currentUrlTree = createEmptyUrlTree();
|
this.currentUrlTree = createEmptyUrlTree();
|
||||||
this.currentRouterState = createEmptyState(this.rootComponentType);
|
this.currentRouterState = createEmptyState(this.rootComponentType);
|
||||||
|
|
|
@ -23,8 +23,8 @@ import {RouterConfig} from './config';
|
||||||
* bootstrap(AppCmp, [provideRouter(router)]);
|
* bootstrap(AppCmp, [provideRouter(router)]);
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export function provideRouter(config: RouterConfig): any[] {
|
export function provideRouter(config: RouterConfig, opts: common.ExtraOptions = {}): any[] {
|
||||||
return [
|
return [
|
||||||
{provide: PlatformLocation, useClass: BrowserPlatformLocation}, ...common.provideRouter(config)
|
{provide: PlatformLocation, useClass: BrowserPlatformLocation}, ...common.provideRouter(config, opts)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
"src/url_serializer.ts",
|
"src/url_serializer.ts",
|
||||||
"src/url_tree.ts",
|
"src/url_tree.ts",
|
||||||
"src/shared.ts",
|
"src/shared.ts",
|
||||||
|
"src/common_router_providers.ts",
|
||||||
"src/router_providers.ts",
|
"src/router_providers.ts",
|
||||||
"src/create_url_tree.ts",
|
"src/create_url_tree.ts",
|
||||||
"src/directives/router_outlet.ts",
|
"src/directives/router_outlet.ts",
|
||||||
|
|
Loading…
Reference in New Issue