离子 - 如何设置DocumentViewer以显示离子内容

时间:2017-06-14 11:50:11

标签: ionic-framework documentviewer

我是Ionic和Angular的新手。我已经正确设置了我的离子,创建了我的应用程序“myApp”并安装了我想要使用的DocumentViewer插件。我甚至通过以下代码在app.module.ts和app.component.ts中导入了它:

import { DocumentViewer} from '@ionic-native/document-viewer'

甚至可以在Providers Array中加载:

  providers: [
    DocumentViewer,
    StatusBar,
    SplashScreen,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]

apps.component.ts代码:

  constructor(public document: DocumentViewer, platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
    platform.ready().then(() => {
      // Okay, so the platform is ready and our plugins are available.
      // Here you can do any higher level native things you might need.
      statusBar.styleDefault();
      splashScreen.hide();
      this.document.viewDocument('../assets/Mary.pdf', 'application/pdf');
    });
  }

问题是如何在我创建的详细信息页面中显示文件?我用Google搜索,但没有相关的答案对我有帮助。我很感激你的帮助。

我的详情页面:

<ion-header>

  <ion-navbar>
    <ion-title>{{item.text}}</ion-title>
  </ion-navbar>

</ion-header>


<ion-content padding>
  <h2>Welcome #{{item.id}}</h2>
  <p>
    Great job!

  </p>
</ion-content>

0 个答案:

没有答案