@ -38,16 +38,15 @@ export class Route implements RouteDefinition {
|
||||
path: string;
|
||||
component: Type;
|
||||
name: string;
|
||||
// added next two properties to work around https://github.com/Microsoft/TypeScript/issues/4107
|
||||
loader: Function;
|
||||
redirectTo: string;
|
||||
// added next three properties to work around https://github.com/Microsoft/TypeScript/issues/4107
|
||||
aux: string = null;
|
||||
loader: Function = null;
|
||||
redirectTo: string = null;
|
||||
constructor({path, component, name,
|
||||
data}: {path: string, component: Type, name?: string, data?: {[key: string]: any}}) {
|
||||
this.path = path;
|
||||
this.component = component;
|
||||
this.name = name;
|
||||
this.loader = null;
|
||||
this.redirectTo = null;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@ -78,7 +77,8 @@ export class AuxRoute implements RouteDefinition {
|
||||
path: string;
|
||||
component: Type;
|
||||
name: string;
|
||||
// added next two properties to work around https://github.com/Microsoft/TypeScript/issues/4107
|
||||
// added next three properties to work around https://github.com/Microsoft/TypeScript/issues/4107
|
||||
aux: string = null;
|
||||
loader: Function = null;
|
||||
redirectTo: string = null;
|
||||
constructor({path, component, name}: {path: string, component: Type, name?: string}) {
|
||||
@ -115,6 +115,7 @@ export class AsyncRoute implements RouteDefinition {
|
||||
path: string;
|
||||
loader: Function;
|
||||
name: string;
|
||||
aux: string = null;
|
||||
constructor({path, loader, name, data}:
|
||||
{path: string, loader: Function, name?: string, data?: {[key: string]: any}}) {
|
||||
this.path = path;
|
||||
@ -148,9 +149,10 @@ export class Redirect implements RouteDefinition {
|
||||
path: string;
|
||||
redirectTo: string;
|
||||
name: string = null;
|
||||
// added next property to work around https://github.com/Microsoft/TypeScript/issues/4107
|
||||
// added next three properties to work around https://github.com/Microsoft/TypeScript/issues/4107
|
||||
loader: Function = null;
|
||||
data: any = null;
|
||||
aux: string = null;
|
||||
constructor({path, redirectTo}: {path: string, redirectTo: string}) {
|
||||
this.path = path;
|
||||
this.redirectTo = redirectTo;
|
||||
|
@ -26,6 +26,9 @@ export function normalizeRouteConfig(config: RouteDefinition): RouteDefinition {
|
||||
if (config.loader) {
|
||||
return new AsyncRoute({path: config.path, loader: config.loader, name: config.name});
|
||||
}
|
||||
if (config.aux) {
|
||||
return new AuxRoute({path: config.aux, component:<Type>config.component, name: config.name});
|
||||
}
|
||||
if (config.component) {
|
||||
if (typeof config.component == 'object') {
|
||||
let componentDefinitionObject = <ComponentDefinition>config.component;
|
||||
|
@ -4,7 +4,7 @@ import {CONST, Type} from 'angular2/src/core/facade/lang';
|
||||
* `RouteDefinition` defines a route within a {@link RouteConfig} decorator.
|
||||
*
|
||||
* Supported keys:
|
||||
* - `path` (required)
|
||||
* - `path` or `aux` (requires exactly one of these)
|
||||
* - `component`, `loader`, `redirectTo` (requires exactly one of these)
|
||||
* - `name` or `as` (optional) (requires exactly one of these)
|
||||
* - `data` (optional)
|
||||
@ -12,7 +12,8 @@ import {CONST, Type} from 'angular2/src/core/facade/lang';
|
||||
* See also {@link Route}, {@link AsyncRoute}, {@link AuxRoute}, and {@link Redirect}.
|
||||
*/
|
||||
export interface RouteDefinition {
|
||||
path: string;
|
||||
path?: string;
|
||||
aux?: string;
|
||||
component?: Type | ComponentDefinition;
|
||||
loader?: Function;
|
||||
redirectTo?: string;
|
||||
|
@ -337,8 +337,11 @@ export class Router {
|
||||
}
|
||||
|
||||
var promises = [];
|
||||
this._auxRouters.forEach(
|
||||
(router, name) => { promises.push(router.commit(instruction.auxInstruction[name])); });
|
||||
this._auxRouters.forEach((router, name) => {
|
||||
if (isPresent(instruction.auxInstruction[name])) {
|
||||
promises.push(router.commit(instruction.auxInstruction[name]));
|
||||
}
|
||||
});
|
||||
|
||||
return next.then((_) => PromiseWrapper.all(promises));
|
||||
}
|
||||
|
Reference in New Issue
Block a user