首页 > 解决方案 > 如何正确地为 ng2-pdf-viewer 提供路径

问题描述

问题:

我创建了一个角度应用程序。我正在使用 ng2-pdf-viewer。我在这样的 HTML 文件上访问它。

<pdf-viewer
      [src]="https://myback.mydomain.lk/{{gov?.source_pdf_ref}}"
      [render-text]="true"
      style="display: block;"
    ></pdf-viewer>

我面临的问题是我正在动态呈现 pdf 文件的路径。我所做的事情导致了这个错误。

未捕获的错误:报价不支持评估!声明: //myback.mydomain.lk.lk/{{gov?.source_pdf_ref}} 位于 ng:///UserLayoutModule/GovenmentTabComponent.html@110:6 at _AstToIrVisitor.push../node_modules/@angular/compiler/ fesm5/compiler.js._AstToIrVisitor.visitQuote (compiler.js:7380) at Quote.push../node_modules/@angular/compiler/fesm5/compiler.js.Quote.visit (compiler.js:6206) at convertPropertyBinding (compiler .js:7084) at compiler.js:22230 at Array.map () at createUpdateStatements (compiler.js:22226) at compiler.js:22211 at Array.map () at ViewBuilder.push../node_modules/@angular/编译器/fesm5/compiler.js.ViewBuilder._createNodeExpressions (compiler.js:22205) 在 ViewBuilder.push../node_modules/@angular/compiler/fesm5/compiler.js.ViewBuilder.build (编译器。

我尝试了很多在互联网上找到解决此问题的方法,但我无法这样做。有人可以帮我解决这个问题或提出一个好的方法吗?谢谢你。

标签: angularng2-pdfjs-viewer

解决方案


你不应该混合属性绑定和插值:

试试这个:

[src]="'https://myback.mydomain.lk/' + gov?.source_pdf_ref"

推荐阅读