angular - DOM 不使用 componentFactory 渲染
问题描述
要求:ngx-extended-pdf-viewer
使用 Angular 9 在弹出窗口中打开
问题:
`ngx-extended-pdf-viewer` couldn't loaded
在 TS 中:
open(): void {
const componentFactory = this.resolver.resolveComponentFactory(WindowComponent);
let componentRef = componentFactory.create(this.injector);
this.applicationRef.attachView(componentRef.hostView);
// get DOM element from component
const domElem = (componentRef.hostView as EmbeddedViewRef < any > )
.rootNodes[0] as HTMLElement;
this.OpenWindow = window.open('', 'childwindow', 'width=400,height=400,left=150,top=200');
this.OpenWindow.document.body.innerHTML = "";
this.OpenWindow.document.body.appendChild(domElem);
}
解决方案
推荐阅读
- .htaccess - 我可以将所有旧的非查询字符串 url 重定向到新的 url
- python - 如何将纬度/经度坐标从度数转换为公里数以创建 1 公里网格
- powerbi - 允许外部用户编辑报告
- google-apps-script - 带有日期的 Google 表单 createResponse 将日期递减 1
- reactjs - 使用 React 添加/删除输入字段
- powershell - PowerShell 使用另一个变量调用环境变量
- c# - RaspberryPi 上的 UWP C# BrightnessOverride 类
- web-services - 通过 ICF 处理程序类将多个文件发送到 REST 服务
- javascript - 如何从 Laravel 的 javascript 刀片上的控制器获取数组
- php - Wordpress - 后端 AJAX 调用返回 0