简体   繁体   English

在AngularJS html5mode express环境中提供文件下载

[英]Serving a file download in a AngularJS html5mode express environment

I'm trying to serve a pdf file download on a app essentially generated with the angular-fullstack yeoman generator. 我正在尝试在本质上由angular-fullstack yeoman生成器生成的应用程序上提供pdf文件下载。

In app.js html5mode is set to true. 在app.js中,html5mode设置为true。

I tried building a download link using an tag and href but just nothing happens. 我尝试使用标签和href建立下载链接,但没有任何反应。 Watching network activity reveals, that it's not generating an get request. 观察网络活动表明,它没有生成获取请求。

Server backend is an express server serving partials and other stuff. 服务器后端是服务于局部和其他内容的快速服务器。

How can i do this ? 我怎样才能做到这一点 ?

Why not put the file download link on the subdomain like file.domain.com ? 为什么不将文件下载链接放在像file.domain.com这样的子域上?

This example might be help you to set up subdomain in your express application. 此示例可能有助于您在快速应用程序中设置子域。

EDIT: 编辑:

Just put target="_self" on your link. 只需将target="_self"放在您的链接上即可。

Example: <a href="/link/to/file" target="_self">link</a> 示例: <a href="/link/to/file" target="_self">link</a>

Source: Conditionally have anchor links send user to a different page, rather than load to ng-view 来源: 有条件地使用锚链接将用户发送到其他页面,而不是加载到ng-view

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

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