diff --git a/lib/src/ng2-pdfjs-viewer.component.ts b/lib/src/ng2-pdfjs-viewer.component.ts index 6dbf1a4f..586ab060 100644 --- a/lib/src/ng2-pdfjs-viewer.component.ts +++ b/lib/src/ng2-pdfjs-viewer.component.ts @@ -1,10 +1,10 @@ -import { Component, Input, Output, OnInit, ViewChild, EventEmitter, ElementRef } from '@angular/core'; +import { Component, Input, Output, OnInit, OnDestroy, ViewChild, EventEmitter, ElementRef } from '@angular/core'; @Component({ selector: 'ng2-pdfjs-viewer', template: `` }) -export class PdfJsViewerComponent implements OnInit { +export class PdfJsViewerComponent implements OnInit, OnDestroy { @ViewChild('iframe', { static: true }) iframe: ElementRef; static lastID = 0; @Input() public viewerId = `ng2-pdfjs-viewer-ID${++PdfJsViewerComponent.lastID}`; @@ -341,4 +341,8 @@ export class PdfJsViewerComponent implements OnInit { // pagemode = ${this.errorMessage} // `); } + + ngOnDestroy(): void { + this.relaseUrl?.(); + } }