angularjs - Ionic 2 display a PDF in an ionic page/modal -


hi want display pdf inside ionic page display on android , ios phones. not sure best way this, trying http://ionicframework.com/docs/native/document-viewer/ no luck, able assist? thanks

home.html

<button ion-button clear (click)="openmodal('assets/pdf/filename.pdf')">     <h2>link</h2> </button> <button ion-button clear (click)="openmodal('assets/pdf/filename2.pdf')">     <h2>link 2</h2> </button> 

home.ts

import { component } '@angular/core'; import { navcontroller } 'ionic-angular'; import { pdfpage } '../pdfviewer/pdfviewer'; import { modalcontroller } 'ionic-angular'; import { documentviewer } '@ionic-native/document-viewer';  @component({     selector: 'page-home',     templateurl: 'home.html' }) export class homepage {     constructor(public navctrl: navcontroller,public modalctrl: modalcontroller,private document: documentviewer) { }     const options: documentvieweroptions = {       title: 'my pdf'     }     openmodal(value) {         let mymodal = this.modalctrl.create(pdfpage);         mymodal.present();         this.document.viewdocument(value, 'application/pdf', options);     } } 

pdfviewer.html

<ion-content padding>     <ion-icon large name="close-circle" (click)="closemodal()" float-right style="z-index:9999;font-size:3.5em;padding:20px"></ion-icon> </ion-content> 

pdfviewer.ts

import { component } '@angular/core'; import { navcontroller } 'ionic-angular'; import { viewcontroller } 'ionic-angular'; import { homepage } '../home/home';  @component({     selector: 'page-pdf',     templateurl: 'pdfviewer.html' }) export class pdfpage {      constructor(public navctrl: navcontroller,public viewctrl: viewcontroller) { }      closemodal() {         this.viewctrl.dismiss();     } } 

i added import { documentviewer } '@ionic-native/document-viewer'; app.module.ts in provider.

these errors:

typescript error class member cannot have 'const' keyword.

typescript error cannot find name 'documentvieweroptions'.

typescript error cannot find name 'options'. did mean instance member 'this.options'?

try import as

import { documentviewer, documentvieweroptions } '@ionic-native/document-viewer';


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -