Reputation: 31
im trying to open pdf a file received via api from angular cordova application.
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');
how to define cordova? import { } from "cordova-plugin-inappbrowser" ?. im not using ionic simple angular application using phonegap cordova
Upvotes: 1
Views: 1879
Reputation: 10237
You can use cordova instance
the following ways
(window as any).cordova.InAppBrowser.open(fileURL, '_blank', 'location=yes');
OR
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');
}
}
Upvotes: 1