throws undefined error

This commit is contained in:
Dan Percic 2021-04-19 17:24:34 +03:00
parent 160220ce4e
commit 81e0498e48
2 changed files with 11 additions and 2 deletions

View File

@ -418,7 +418,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges {
}
}
private _loadDocument() {
public _loadDocument() {
if (this.fileData) {
this.instance.loadDocument(this.fileData, {
filename: this.fileStatus ? this.fileStatus.filename : 'document.pdf'

View File

@ -1,5 +1,5 @@
import { ChangeDetectorRef, Component, HostListener, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { ActivatedRoute, Event, NavigationEnd, Router } from '@angular/router';
import { AppStateService } from '../../../../state/app-state.service';
import { WebViewerInstance } from '@pdftron/webviewer';
import { PdfViewerComponent } from '../../components/pdf-viewer/pdf-viewer.component';
@ -191,6 +191,15 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy {
});
}
});
this._router.events.subscribe((event: Event) => {
if (event instanceof NavigationEnd) {
console.log(event);
if (!event.url.includes('?page=') && event.url.includes('/ui/projects/') && event.url.includes('/file/')) {
this._viewerComponent._loadDocument();
}
}
});
}
ngOnDestroy(): void {