Skip to content

Commit

Permalink
Merge pull request #37 from delian/master
Browse files Browse the repository at this point in the history
Fix the case where src is still not having a value
  • Loading branch information
VadimDez authored Dec 19, 2016
2 parents 0fcf6cf + a8f05f9 commit 46bac29
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/pdf-viewer/pdf-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class PdfViewerComponent extends OnInit {
set src(_src) {
this._src = _src;

if (this.isInitialised) {
if (this.isInitialised && this._src) {
this.main();
}
}
Expand Down Expand Up @@ -143,16 +143,18 @@ export class PdfViewerComponent extends OnInit {
}

private loadPDF(src) {
(<any>window).PDFJS.getDocument(src).then((pdf: any) => {
this._pdf = pdf;
this.lastLoaded = src;
if (src) {
(<any>window).PDFJS.getDocument(src).then((pdf: any) => {
this._pdf = pdf;
this.lastLoaded = src;

if (this.afterLoadComplete && typeof this.afterLoadComplete === 'function') {
this.afterLoadComplete(pdf);
}
if (this.afterLoadComplete && typeof this.afterLoadComplete === 'function') {
this.afterLoadComplete(pdf);
}

this.onRender();
});
this.onRender();
});
}
}

private onRender() {
Expand Down Expand Up @@ -266,4 +268,4 @@ export class PdfViewerComponent extends OnInit {
element.removeChild(element.firstChild);
}
}
}
}

0 comments on commit 46bac29

Please sign in to comment.