angular2
Version:
Angular 2 - a web framework for modern web apps
34 lines (31 loc) • 1.04 kB
text/typescript
import {
ResolvedReflectiveProvider,
Directive,
DynamicComponentLoader,
ViewContainerRef,
Input,
ComponentRef,
ComponentFactory,
ReflectiveInjector
} from 'angular2/core';
import {RouterOutletMap} from '../router';
import {isPresent} from 'angular2/src/facade/lang';
export class RouterOutlet {
private _loaded: ComponentRef;
public outletMap: RouterOutletMap;
name: string = "";
constructor(parentOutletMap: RouterOutletMap, private _location: ViewContainerRef) {
parentOutletMap.registerOutlet("", this);
}
load(factory: ComponentFactory, providers: ResolvedReflectiveProvider[],
outletMap: RouterOutletMap): ComponentRef {
if (isPresent(this._loaded)) {
this._loaded.destroy();
}
this.outletMap = outletMap;
let inj = ReflectiveInjector.fromResolvedProviders(providers, this._location.parentInjector);
this._loaded = this._location.createComponent(factory, this._location.length, inj, []);
return this._loaded;
}
}