1

Problem:

I have created an angular application. There I am using ng2-pdf-viewer. I accessed it on an HTML file like this.

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

The problem that I faced is I am rendering path to pdf file dynamically. The thing I have done cause to this error.

Uncaught Error: Quotes are not supported for evaluation! Statement: //myback.mydomain.lk.lk/{{gov?.source_pdf_ref}} located at 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/compiler/fesm5/compiler.js.ViewBuilder._createNodeExpressions (compiler.js:22205) at ViewBuilder.push../node_modules/@angular/compiler/fesm5/compiler.js.ViewBuilder.build (compiler.js:21677)

I tried a lot to find out a solution to this problem on the internet but I was unable to do so. Can someone help me to solve this Issue or suggests a good way to do this? Thank you.

2 Answers2

1

You shouldn't mix property binding and interpolation:

Try this one:

[src]="'https://myback.mydomain.lk/' + gov?.source_pdf_ref"
yurzui
  • 205,937
  • 32
  • 433
  • 399
0

You can try this:

<pdf-viewer
  src="https://myback.mydomain.lk/{{gov?.source_pdf_ref}}"
  [render-text]="true"
  style="display: block;"
></pdf-viewer>
Dino
  • 7,779
  • 12
  • 46
  • 85
Sourav Golui
  • 583
  • 1
  • 6
  • 13