angular - 如何正确地为 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 (编译器。
我尝试了很多在互联网上找到解决此问题的方法,但我无法这样做。有人可以帮我解决这个问题或提出一个好的方法吗?谢谢你。
解决方案
你不应该混合属性绑定和插值:
试试这个:
[src]="'https://myback.mydomain.lk/' + gov?.source_pdf_ref"
推荐阅读
- tdd - 将 TDD 从业务级别分解到单元级别的有效技术是什么?
- jquery - 在 DataTables 中动态插入行
- database - 如何重新验证 Db2 中的特定视图
- javascript - W3C Google Chrome 支付请求 API 错误:不支持支付方式“基本卡”
- java - 如何使用 CriteriaBuilder API 链接连接
- performance - 我可以将向量移动到结构内部而不完全复制它吗?
- pandas - 根据列表过滤数据框列
- powerbi - 计算过滤器上下文之外的值 - Powerbi
- python - python子进程将stdin和stdout捕获到变量中
- sql - WHERE IN 在 Redshift 中有多个列