angular - Angular 8:我可以在 window.open 中使用 ngx-barcode 吗?
问题描述
我可以在 window.open 中使用 ngx-barcode 吗?如何?
modalPrint.document.write('<tr><td class="text-center"><ngx-barcode [bc-value]="value" [bc-display-value]="true"></ngx-barcode></td></tr>');
这是行不通的。或者我需要添加一个库的东西?
解决方案
您应该以这种方式在您的角度组件中导入文档对象:
import { Inject, Injectable } from '@angular/core';
import { DOCUMENT } from '@angular/platform-browser';
So you can use it as the following :
@Injectable()
export class MyService {
constructor(@Inject(DOCUMENT) private document: any) {
document.write(your_code_here);
}
}
推荐阅读
- r - geom_contour_filled 调色板
- java - 在创建非常大的列表块时内存不足
- batch-file - 从命令提示符读取批处理文件
- python - Pandas Plot:如何在同一个 pdf 文件中导出数据框和图形?
- c - 将代码从 C 转换为 Delphi(使用 DLL)
- azure - 部署任务后有没有办法将文件作为 VSTS 任务删除?
- mysql - QLSTATE[HY000] [2002] 连接被拒绝 (SQL: select * from inform)
- regex - 优化 Go 中正则表达式的内存消耗
- angular - angular 9 videogular2 无法解析为 NgModule
- python - 如何使用python中的函数从以前的列表中打印新列表?