From d5d1acfc21823fc75ca8cab6a3f7f4204b41150f Mon Sep 17 00:00:00 2001 From: Ilya Surmay Date: Mon, 4 Dec 2017 13:40:55 +0200 Subject: [PATCH] fix(modal): fix memory leak for TemplateRef modals (#3179) --- src/component-loader/component-loader.class.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/component-loader/component-loader.class.ts b/src/component-loader/component-loader.class.ts index 8f6944d7f9..14597d51d2 100644 --- a/src/component-loader/component-loader.class.ts +++ b/src/component-loader/component-loader.class.ts @@ -205,6 +205,9 @@ export class ComponentLoader { this._viewContainerRef.indexOf(this._contentRef.viewRef) ); } + if (this._contentRef.viewRef) { + this._contentRef.viewRef.destroy(); + } // this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._componentRef.hostView)); // // if (this._contentRef.viewRef && this._viewContainerRef.indexOf(this._contentRef.viewRef) !== -1) {