diff --git a/src/cdk/table/table.ts b/src/cdk/table/table.ts index 3ed73c43b66d..91b0129b047a 100644 --- a/src/cdk/table/table.ts +++ b/src/cdk/table/table.ts @@ -611,13 +611,23 @@ export class CdkTable implements AfterContentChecked, CollectionViewer, OnDes } ngOnDestroy() { - this._rowOutlet.viewContainer.clear(); - this._noDataRowOutlet.viewContainer.clear(); - this._headerRowOutlet.viewContainer.clear(); - this._footerRowOutlet.viewContainer.clear(); - - this._cachedRenderRowsMap.clear(); + [ + this._rowOutlet.viewContainer, + this._headerRowOutlet.viewContainer, + this._footerRowOutlet.viewContainer, + this._cachedRenderRowsMap, + this._customColumnDefs, + this._customRowDefs, + this._customHeaderRowDefs, + this._customFooterRowDefs, + this._columnDefsByName + ].forEach(def => { + def.clear(); + }); + this._headerRowDefs = []; + this._footerRowDefs = []; + this._defaultRowDef = null; this._onDestroy.next(); this._onDestroy.complete();