diff --git a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts index 70f4b63217..8130c51367 100644 --- a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts +++ b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-bundle/item-edit-bitstream-bundle.component.ts @@ -1,4 +1,4 @@ -import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewContainerRef } from '@angular/core'; +import { Component, EventEmitter, Input, OnInit, Output, ViewChild, ViewContainerRef, OnDestroy } from '@angular/core'; import { Bundle } from '../../../../core/shared/bundle.model'; import { Item } from '../../../../core/shared/item.model'; import { ResponsiveColumnSizes } from '../../../../shared/responsive-table-sizes/responsive-column-sizes'; @@ -16,7 +16,7 @@ import { DSONameService } from '../../../../core/breadcrumbs/dso-name.service'; * Creates an embedded view of the contents. This is to ensure the table structure won't break. * (which means it'll be added to the parents html without a wrapping ds-item-edit-bitstream-bundle element) */ -export class ItemEditBitstreamBundleComponent implements OnInit { +export class ItemEditBitstreamBundleComponent implements OnInit, OnDestroy { /** * The view on the bundle information and bitstreams @@ -67,4 +67,9 @@ export class ItemEditBitstreamBundleComponent implements OnInit { this.viewContainerRef.createEmbeddedView(this.bundleView); this.itemPageRoute = getItemPageRoute(this.item); } + + ngOnDestroy(): void { + this.viewContainerRef.clear(); + } + } diff --git a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-drag-handle/item-edit-bitstream-drag-handle.component.ts b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-drag-handle/item-edit-bitstream-drag-handle.component.ts index e5cb9ba403..d9c9a8f34a 100644 --- a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-drag-handle/item-edit-bitstream-drag-handle.component.ts +++ b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream-drag-handle/item-edit-bitstream-drag-handle.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, ViewChild, ViewContainerRef } from '@angular/core'; +import { Component, OnInit, ViewChild, ViewContainerRef, OnDestroy } from '@angular/core'; @Component({ selector: 'ds-item-edit-bitstream-drag-handle', @@ -10,7 +10,7 @@ import { Component, OnInit, ViewChild, ViewContainerRef } from '@angular/core'; * Creates an embedded view of the contents * (which means it'll be added to the parents html without a wrapping ds-item-edit-bitstream-drag-handle element) */ -export class ItemEditBitstreamDragHandleComponent implements OnInit { +export class ItemEditBitstreamDragHandleComponent implements OnInit, OnDestroy { /** * The view on the drag-handle */ @@ -23,4 +23,8 @@ export class ItemEditBitstreamDragHandleComponent implements OnInit { this.viewContainerRef.createEmbeddedView(this.handleView); } + ngOnDestroy(): void { + this.viewContainerRef.clear(); + } + } diff --git a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream/item-edit-bitstream.component.ts b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream/item-edit-bitstream.component.ts index fcb5c706ac..43c201aa9a 100644 --- a/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream/item-edit-bitstream.component.ts +++ b/src/app/item-page/edit-item-page/item-bitstreams/item-edit-bitstream/item-edit-bitstream.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnChanges, OnInit, SimpleChanges, ViewChild, ViewContainerRef } from '@angular/core'; +import { Component, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild, ViewContainerRef } from '@angular/core'; import { Bitstream } from '../../../../core/shared/bitstream.model'; import cloneDeep from 'lodash/cloneDeep'; import { ObjectUpdatesService } from '../../../../core/data/object-updates/object-updates.service'; @@ -21,7 +21,7 @@ import { getBitstreamDownloadRoute } from '../../../../app-routing-paths'; * Creates an embedded view of the contents * (which means it'll be added to the parents html without a wrapping ds-item-edit-bitstream element) */ -export class ItemEditBitstreamComponent implements OnChanges, OnInit { +export class ItemEditBitstreamComponent implements OnChanges, OnDestroy, OnInit { /** * The view on the bitstream @@ -72,6 +72,10 @@ export class ItemEditBitstreamComponent implements OnChanges, OnInit { this.viewContainerRef.createEmbeddedView(this.bitstreamView); } + ngOnDestroy(): void { + this.viewContainerRef.clear(); + } + /** * Update the current bitstream and its format on changes * @param changes