繁体   English   中英

如何在Angular 4中单击按钮时在其他窗口中显示pdf文件

[英]How to show a pdf file in different window on button click in Angular 4

我是Angular 2的新手。在我的index.html中,我已在此指令内部执行了整个显示。 在此内部,我有3个指令。

<app-header></app-header>
<app-content></app-content>
<app-footer></app-footer>

在其中有一些内容的内部,有一个按钮,单击该按钮,我想在其他窗口中显示一个已经存储在我的项目中的pdf文件。 在该窗口中,只有pdf,没有其他页眉或页脚。 怎么做。 这是我的html代码-

<div class="col-md-8">
     Designed to address massive data processing especially telecom data, storage and real-time analytics on the cloud. Reports and alarms on your handheld.                                        
     <p><a class="btn-u btn-u-sm" target="_blank" [routerLink]="['files/Skybase.pdf']">Download <i class="fa fa-angle-double-right margin-left-5"></i></a></p>
</div>

我不明白在app.module.ts中写什么来路由和显示pdf。

请帮我。

我认为您不应该在这里使用角度路由。 只需添加一个指向pdf文件位置的简单链接( 完整 URL),使用_target=blank ,它将在新选项卡中打开。 一个例子:

<a href="http://www.thesitewizard.com/"; target="_blank">thesitewizard.com</a>

角度路由的目的是在不重新加载同一页面的情况下工作,因此这有点超出角度范围。 Angular用于编写SPA(单页应用程序),而在新选项卡中打开任何内容完全超出范围。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM