How to display empty ng2-pdfjs-viewer when no file provided

故事扮演 提交于 2019-12-24 00:45:33

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!