Angular 2如何显示.pdf文件 [英] Angular 2 how to display .pdf file

查看:470
本文介绍了Angular 2如何显示.pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个angular2应用,我希望用户能够在浏览器中下载并打开pdf文件.

I have an angular2 app, where I want the user to be able to download and open a pdf file in the browser.

有没有我可以使用的angular2模块或组件?

Is there an angular2 module or component that I can use?

推荐答案

您是否看过此模块 https://www.npmjs.com/package/ng2-pdf-viewer ?

记住像这样在模块中声明它

remember to declare it in the module like so

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms'; 
import { HttpModule } from '@angular/http';

import { PdfViewerComponent } from 'ng2-pdf-viewer'; 
import { AppComponent } from './app.component';

@NgModule({
  declarations: [
    AppComponent,
    PdfViewerComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

这篇关于Angular 2如何显示.pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆