feat(router): support deep-linking to anywhere in the app

Closes #2642
This commit is contained in:
Brian Ford
2015-06-30 13:18:51 -07:00
parent 2335075506
commit f66ce096d8
16 changed files with 331 additions and 170 deletions

View File

@ -0,0 +1,21 @@
import {RouteHandler} from './route_handler';
import {Promise, PromiseWrapper} from 'angular2/src/facade/async';
import {isPresent, Type} from 'angular2/src/facade/lang';
export class AsyncRouteHandler implements RouteHandler {
_resolvedComponent: Promise<any> = null;
componentType: Type;
constructor(private _loader: Function) {}
resolveComponentType(): Promise<any> {
if (isPresent(this._resolvedComponent)) {
return this._resolvedComponent;
}
return this._resolvedComponent = this._loader().then((componentType) => {
this.componentType = componentType;
return componentType;
});
}
}