angular-cn/modules/angular2/src/router/route_config_impl.ts
Alex Eagle 3c58878b19 chore(build): Upgrade to TypeScript@1.5.3
This change also makes us compliant with 1.6.0-dev compiler,
so we can do some experiments with apps that use 1.6 features
and compile against Angular.

We should probably add a travis build for 1.6 so we stay compatible
with both versions.
2015-07-31 20:01:27 +00:00

59 lines
1.5 KiB
TypeScript

import {CONST, Type} from 'angular2/src/facade/lang';
import {List} from 'angular2/src/facade/collection';
import {RouteDefinition} from './route_definition';
export {RouteDefinition} from './route_definition';
/**
* You use the RouteConfig annotation to add routes to a component.
*
* Supported keys:
* - `path` (required)
* - `component`, `redirectTo` (requires exactly one of these)
* - `as` (optional)
*/
@CONST()
export class RouteConfig {
constructor(public configs: List<RouteDefinition>) {}
}
@CONST()
export class Route implements RouteDefinition {
path: string;
component: Type;
as: string;
// added next two properties to work around https://github.com/Microsoft/TypeScript/issues/4107
loader: Function;
redirectTo: string;
constructor({path, component, as}: {path: string, component: Type, as?: string}) {
this.path = path;
this.component = component;
this.as = as;
this.loader = null;
this.redirectTo = null;
}
}
@CONST()
export class AsyncRoute implements RouteDefinition {
path: string;
loader: Function;
as: string;
constructor({path, loader, as}: {path: string, loader: Function, as?: string}) {
this.path = path;
this.loader = loader;
this.as = as;
}
}
@CONST()
export class Redirect implements RouteDefinition {
path: string;
redirectTo: string;
as: string = null;
constructor({path, redirectTo}: {path: string, redirectTo: string}) {
this.path = path;
this.redirectTo = redirectTo;
}
}