问题
I'm using ng2-pdfjs-viewer to display pdfs in my angular page:
<ng2-pdfjs-viewer [pdfSrc]="src">
</ng2-pdfjs-viewer>
Behavior : i get src from server, when it's not empty or null it's working correctly, but when null or emty ng2-pdfjs-viewer crashes.
Expeced : display an empty ng2-pdfjs-viewer when src is null or empty (or a loading indicator inside)
回答1:
Put *ngIf with this component. It will solve null or empty src case.
<ng2-pdfjs-viewer *ngIf="src" [pdfSrc]="src">
</ng2-pdfjs-viewer>
来源:https://stackoverflow.com/questions/58136515/how-to-display-empty-ng2-pdfjs-viewer-when-no-file-provided