如何正确给出ng2-pdf-viewer的路径

问题描述 投票:0回答:2

问题:

我创建了一个有角度的应用程序。我正在使用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在_AstToIrVisitor.push ../ node_modules/@angular/compiler/fesm5/compiler.js._AstToIrVisitor.visitQuote(compiler.js:7380)在Quote.push ../ node_modules/@angular/compiler/fesm5/compiler.js.Quote.visit(compiler.js:6206)在convertPropertyBinding(compiler.js:7084)在compile.js:22230在Array.map()在createUpdateStatements(compiler.js:22226)在compile.js:22211在Array.map()在ViewBuilder.push ../ node_modules/@angular/compiler/fesm5/compiler.js.ViewBuilder._createNodeExpressions(compiler.js:22205)在ViewBuilder.push ../ node_modules/@angular/compiler/fesm5/compiler.js.ViewBuilder.build(compiler.js:21677)

我做了很多尝试,以在Internet上找到解决此问题的方法,但我无法做到。有人可以帮助我解决此问题或提出解决此问题的好方法吗?谢谢。

angular ng2-pdfjs-viewer
2个回答
0
投票

您不应混合使用属性绑定和插值:

尝试这个:

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

0
投票

您可以尝试以下方法:

<pdf-viewer
  src="https://myback.mydomain.lk/{{gov?.source_pdf_ref}}"
  [render-text]="true"
  style="display: block;"
></pdf-viewer>
© www.soinside.com 2019 - 2024. All rights reserved.