简体   繁体   English

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

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

I am new to Angular 2. Inside my index.html i have directive inside of this my whole display is coming. 我是Angular 2的新手。在我的index.html中,我已在此指令内部执行了整个显示。 Inside of this I have 3 directives. 在此内部,我有3个指令。

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

Inside of with some contents I have a button, on click of that I want to show a pdf file, which already stored in my project, in different window. 在其中有一些内容的内部,有一个按钮,单击该按钮,我想在其他窗口中显示一个已经存储在我的项目中的pdf文件。 In that window only pdf will be there, no other header or footer. 在该窗口中,只有pdf,没有其他页眉或页脚。 How to do that. 怎么做。 It's my html code- 这是我的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>

I don't understand what to write in app.module.ts for routing and showing the pdf. 我不明白在app.module.ts中写什么来路由和显示pdf。

Please help me. 请帮我。

I think you should not use angular routing here. 我认为您不应该在这里使用角度路由。 Just add a simple link to the pdf file location ( full url), use _target=blank , so it will open in a new tab. 只需添加一个指向pdf文件位置的简单链接( 完整 URL),使用_target=blank ,它将在新选项卡中打开。 An example: 一个例子:

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

Angular routing is meant to work without reloading the same page, so this is kinda out of scope for angular. 角度路由的目的是在不重新加载同一页面的情况下工作,因此这有点超出角度范围。 Angular is meant for writing SPA (single page applications) and opening anything in a new tab is completely out of scope. Angular用于编写SPA(单页应用程序),而在新选项卡中打开任何内容完全超出范围。

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

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