UNPKG

angular2

Version:

Angular 2 - a web framework for modern web apps

167 lines 5.66 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { if (typeof Reflect === "object" && typeof Reflect.decorate === "function") return Reflect.decorate(decorators, target, key, desc); switch (arguments.length) { case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target); case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0); case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc); } }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { CONST } from 'angular2/src/facade/lang'; /** * The `RouteConfig` decorator defines routes for a given component. * * It takes an array of {@link RouteDefinition}s. */ export let RouteConfig = class { constructor(configs) { this.configs = configs; } }; RouteConfig = __decorate([ CONST(), __metadata('design:paramtypes', [Array]) ], RouteConfig); /** * `Route` is a type of {@link RouteDefinition} used to route a path to a component. * * It has the following properties: * - `path` is a string that uses the route matcher DSL. * - `component` a component type. * - `name` is an optional `CamelCase` string representing the name of the route. * - `data` is an optional property of any type representing arbitrary route metadata for the given * route. It is injectable via {@link RouteData}. * * ### Example * ``` * import {RouteConfig} from 'angular2/router'; * * @RouteConfig([ * {path: '/home', component: HomeCmp, name: 'HomeCmp' } * ]) * class MyApp {} * ``` */ export let Route = class { constructor({ path, component, name, data }) { // added next three properties to work around https://github.com/Microsoft/TypeScript/issues/4107 this.aux = null; this.loader = null; this.redirectTo = null; this.path = path; this.component = component; this.name = name; this.data = data; } }; Route = __decorate([ CONST(), __metadata('design:paramtypes', [Object]) ], Route); /** * `AuxRoute` is a type of {@link RouteDefinition} used to define an auxiliary route. * * It takes an object with the following properties: * - `path` is a string that uses the route matcher DSL. * - `component` a component type. * - `name` is an optional `CamelCase` string representing the name of the route. * - `data` is an optional property of any type representing arbitrary route metadata for the given * route. It is injectable via {@link RouteData}. * * ### Example * ``` * import {RouteConfig, AuxRoute} from 'angular2/router'; * * @RouteConfig([ * new AuxRoute({path: '/home', component: HomeCmp}) * ]) * class MyApp {} * ``` */ export let AuxRoute = class { constructor({ path, component, name }) { this.data = null; // added next three properties to work around https://github.com/Microsoft/TypeScript/issues/4107 this.aux = null; this.loader = null; this.redirectTo = null; this.path = path; this.component = component; this.name = name; } }; AuxRoute = __decorate([ CONST(), __metadata('design:paramtypes', [Object]) ], AuxRoute); /** * `AsyncRoute` is a type of {@link RouteDefinition} used to route a path to an asynchronously * loaded component. * * It has the following properties: * - `path` is a string that uses the route matcher DSL. * - `loader` is a function that returns a promise that resolves to a component. * - `name` is an optional `CamelCase` string representing the name of the route. * - `data` is an optional property of any type representing arbitrary route metadata for the given * route. It is injectable via {@link RouteData}. * * ### Example * ``` * import {RouteConfig} from 'angular2/router'; * * @RouteConfig([ * {path: '/home', loader: () => Promise.resolve(MyLoadedCmp), name: 'MyLoadedCmp'} * ]) * class MyApp {} * ``` */ export let AsyncRoute = class { constructor({ path, loader, name, data }) { this.aux = null; this.path = path; this.loader = loader; this.name = name; this.data = data; } }; AsyncRoute = __decorate([ CONST(), __metadata('design:paramtypes', [Object]) ], AsyncRoute); /** * `Redirect` is a type of {@link RouteDefinition} used to route a path to an asynchronously loaded * component. * * It has the following properties: * - `path` is a string that uses the route matcher DSL. * - `redirectTo` is a string representing the new URL to be matched against. * * ### Example * ``` * import {RouteConfig} from 'angular2/router'; * * @RouteConfig([ * {path: '/', redirectTo: '/home'}, * {path: '/home', component: HomeCmp} * ]) * class MyApp {} * ``` */ export let Redirect = class { constructor({ path, redirectTo }) { this.name = null; // added next three properties to work around https://github.com/Microsoft/TypeScript/issues/4107 this.loader = null; this.data = null; this.aux = null; this.path = path; this.redirectTo = redirectTo; } }; Redirect = __decorate([ CONST(), __metadata('design:paramtypes', [Object]) ], Redirect); //# sourceMappingURL=route_config_impl.js.map