feat(router): add router metadata
This commit is contained in:
parent
ef6163e652
commit
ef67a0c57f
|
@ -0,0 +1,8 @@
|
|||
library angular.alt_router.decorators;
|
||||
|
||||
import 'metadata.dart';
|
||||
export 'metadata.dart';
|
||||
|
||||
class Routes extends RoutesMetadata {
|
||||
const Routes(List<RouteMetadata> routes): super(routes);
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
import {RoutesMetadata, RouteMetadata} from "./metadata";
|
||||
import {makeDecorator} from 'angular2/src/core/util/decorators';
|
||||
export interface RoutesFactory {
|
||||
(routes: RouteMetadata[]): any;
|
||||
new (routes: RouteMetadata[]): RoutesMetadata;
|
||||
}
|
||||
export var Routes: RoutesFactory = <RoutesFactory>makeDecorator(RoutesMetadata);
|
|
@ -0,0 +1,23 @@
|
|||
import {CONST, Type, stringify} from "angular2/src/facade/lang";
|
||||
|
||||
export abstract class RouteMetadata {
|
||||
abstract get path(): string;
|
||||
abstract get component(): Type;
|
||||
}
|
||||
|
||||
@CONST()
|
||||
export class Route implements RouteMetadata {
|
||||
path: string;
|
||||
component: Type;
|
||||
constructor({path, component}: {path?: string, component?: Type} = {}) {
|
||||
this.path = path;
|
||||
this.component = component;
|
||||
}
|
||||
toString(): string { return `@Route(${this.path}, ${stringify(this.component)})`; }
|
||||
}
|
||||
|
||||
@CONST()
|
||||
export class RoutesMetadata {
|
||||
constructor(public routes: RouteMetadata[]) {}
|
||||
toString(): string { return `@Routes(${this.routes})`; }
|
||||
}
|
Loading…
Reference in New Issue