feat(router): add support for custom route reuse strategies

This commit is contained in:
vsavkin
2016-11-29 23:21:41 -08:00
parent c4bbafc291
commit 42cf06fa12
9 changed files with 319 additions and 35 deletions

View File

@ -67,11 +67,27 @@ export class RouterOutlet implements OnDestroy {
return this._activatedRoute;
}
detach(): ComponentRef<any> {
if (!this.activated) throw new Error('Outlet is not activated');
this.location.detach();
const r = this.activated;
this.activated = null;
this._activatedRoute = null;
return r;
}
attach(ref: ComponentRef<any>, activatedRoute: ActivatedRoute) {
this.activated = ref;
this._activatedRoute = activatedRoute;
this.location.insert(ref.hostView);
}
deactivate(): void {
if (this.activated) {
const c = this.component;
this.activated.destroy();
this.activated = null;
this._activatedRoute = null;
this.deactivateEvents.emit(c);
}
}