angular - cordova-plugin-inappbrowser 不能从角度工作
问题描述
我试图打开 pdf 一个通过 api 从 angular cordova 应用程序接收到的文件。
this.laccountservice.downloadPDF(order).subscribe(
(res) => {
var files= new Blob([res], { type: 'application/pdf' })
console.log(files)
var fileURL = URL.createObjectURL(files);
//window.open(fileURL); // if you want to open it in new tab
cordova.InAppBrowser.open(fileURL, '_blank', 'location=yes');
如何定义科尔多瓦?从“cordova-plugin-inappbrowser”导入{}?我没有使用phonegap cordova的离子简单角度应用程序
解决方案
您可以使用cordova instance
以下方式
(window as any).cordova.InAppBrowser.open(fileURL, '_blank', 'location=yes');
或者
import { Component } from '@angular/core';
declare var cordova:any;
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent {
constructor() {
cordova.InAppBrowser.open(fileURL, '_blank', 'location=yes');
}
}
推荐阅读
- ssh - Vagrant:以下 SSH 命令以非零退出状态响应
- android - 我怎样才能拥有一个可以在中国和东南亚开设iOS/Android商店的二维码?
- python - 如何根据 Python 中的键和值合并两个字典?
- python - Python:通过编程命名变量?
- statistics - 为什么序列相关仍然会产生无偏且一致的参数
- java - 效率:HashMap 检查 containsKey() vs always put()
- angular - 我怎样才能最好地解决 Angular 教程中的这个错误?
- python - 重叠前缀词正则表达式
- python - 如何在python中将变量传递给argparse
- c - 使用 fgets 从 START 到 STOP 字符串读取所有文件字符