angular-cn/modules/angular2/src/router/sync_route_handler.ts
cexbrayat b87da8f47c refactor(router): RouteData as a type
BREAKING CHANGE

The ROUTE_DATA token has been removed and replaced with a type RouteData,
allowing a type injection like we do with RouteParams.

Before:

    constructor(routeParams: RouteParams, @Inject(ROUTE_DATA) routeData) {
      let id = routeParams.get('id');
      let name = ROUTE_DATA.name;
    }

After:

    constructor(routeParams: RouteParams, routeData: RouteData) {
      let id = routeParams.get('id');
      let name = routeData.get('name');
    }

Fixes #4392

Closes #4428
2015-10-27 14:23:44 +00:00

15 lines
521 B
TypeScript

import {RouteHandler} from './route_handler';
import {Promise, PromiseWrapper} from 'angular2/src/core/facade/async';
import {Type} from 'angular2/src/core/facade/lang';
export class SyncRouteHandler implements RouteHandler {
/** @internal */
_resolvedComponent: Promise<any> = null;
constructor(public componentType: Type, public data?: {[key: string]: any}) {
this._resolvedComponent = PromiseWrapper.resolve(componentType);
}
resolveComponentType(): Promise<any> { return this._resolvedComponent; }
}