UNPKG

angular2

Version:

Angular 2 - a web framework for modern web apps

197 lines (196 loc) 6.82 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; 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'; var __make_dart_analyzer_happy = null; /** * The `RouteConfig` decorator defines routes for a given component. * * It takes an array of {@link RouteDefinition}s. */ export let RouteConfig = class RouteConfig { constructor(configs) { this.configs = configs; } }; RouteConfig = __decorate([ CONST(), __metadata('design:paramtypes', [Array]) ], RouteConfig); export let AbstractRoute = class AbstractRoute { constructor({ name, useAsDefault, path, regex, serializer, data }) { this.name = name; this.useAsDefault = useAsDefault; this.path = path; this.regex = regex; this.serializer = serializer; this.data = data; } }; AbstractRoute = __decorate([ CONST(), __metadata('design:paramtypes', [Object]) ], AbstractRoute); /** * `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}. * - `useAsDefault` is a boolean value. If `true`, the child route will be navigated to if no child * route is specified during the navigation. * * ### Example * ``` * import {RouteConfig, Route} from 'angular2/router'; * * @RouteConfig([ * new Route({path: '/home', component: HomeCmp, name: 'HomeCmp' }) * ]) * class MyApp {} * ``` */ export let Route = class Route extends AbstractRoute { constructor({ name, useAsDefault, path, regex, serializer, data, component }) { super({ name: name, useAsDefault: useAsDefault, path: path, regex: regex, serializer: serializer, data: data }); this.aux = null; this.component = component; } }; 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 AuxRoute extends AbstractRoute { constructor({ name, useAsDefault, path, regex, serializer, data, component }) { super({ name: name, useAsDefault: useAsDefault, path: path, regex: regex, serializer: serializer, data: data }); this.component = component; } }; 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}. * - `useAsDefault` is a boolean value. If `true`, the child route will be navigated to if no child * route is specified during the navigation. * * ### Example * ``` * import {RouteConfig, AsyncRoute} from 'angular2/router'; * * @RouteConfig([ * new AsyncRoute({path: '/home', loader: () => Promise.resolve(MyLoadedCmp), name: * 'MyLoadedCmp'}) * ]) * class MyApp {} * ``` */ export let AsyncRoute = class AsyncRoute extends AbstractRoute { constructor({ name, useAsDefault, path, regex, serializer, data, loader }) { super({ name: name, useAsDefault: useAsDefault, path: path, regex: regex, serializer: serializer, data: data }); this.aux = null; this.loader = loader; } }; AsyncRoute = __decorate([ CONST(), __metadata('design:paramtypes', [Object]) ], AsyncRoute); /** * `Redirect` is a type of {@link RouteDefinition} used to route a path to a canonical route. * * It has the following properties: * - `path` is a string that uses the route matcher DSL. * - `redirectTo` is an array representing the link DSL. * * Note that redirects **do not** affect how links are generated. For that, see the `useAsDefault` * option. * * ### Example * ``` * import {RouteConfig, Route, Redirect} from 'angular2/router'; * * @RouteConfig([ * new Redirect({path: '/', redirectTo: ['/Home'] }), * new Route({path: '/home', component: HomeCmp, name: 'Home'}) * ]) * class MyApp {} * ``` */ export let Redirect = class Redirect extends AbstractRoute { constructor({ name, useAsDefault, path, regex, serializer, data, redirectTo }) { super({ name: name, useAsDefault: useAsDefault, path: path, regex: regex, serializer: serializer, data: data }); this.redirectTo = redirectTo; } }; Redirect = __decorate([ CONST(), __metadata('design:paramtypes', [Object]) ], Redirect);