fix(ivy): detach ViewRef from ApplicationRef on destroy (#27276)

Currently we store the `_appRef` when a `ViewRef` is attached, however we don't use it for anything. These changes use it to detach the view from the `ApplicationRef` when it is destroyed. These changes also fix that the `ComponentRef` doesn't remove its `ViewRef` on destroy.

PR Close #27276
This commit is contained in:
Kristiyan Kostadinov
2018-11-26 21:56:29 +01:00
committed by Jason Aden
parent 0487fbe236
commit 4622d0b23a
2 changed files with 265 additions and 231 deletions

View File

@ -59,7 +59,9 @@ export class ViewRef<T> implements viewEngine_EmbeddedViewRef<T>, viewEngine_Int
}
destroy(): void {
if (this._viewContainerRef && viewAttached(this._view)) {
if (this._appRef) {
this._appRef.detachView(this);
} else if (this._viewContainerRef && viewAttached(this._view)) {
this._viewContainerRef.detach(this._viewContainerRef.indexOf(this));
this._viewContainerRef = null;
}