从按钮操作触发的角度下载外部zip文件 [英] Download external zip file from angular triggered on a button action
问题描述
我正在编写一个有角度的应用程序,并且允许用户单击通过 ng-click
调用控制器方法的按钮来下载zip文件.
I'm writing an angular app and I allow users to download zip files by clicking on a button that calls on a controller method via ng-click
.
在angular方法中,我叫 window.open(url,'_self',false)
( window.location.assign(url)
)
Inside the angular method, I'm calling window.open(url, '_self', false)
(the same applies for window.location.assign(url)
)
zip下载正常,但是我在Chrome浏览器中看到此警告:
The zip download is working fine, however I'm seeing this warning in Chrome:
资源被解释为文档,但以MIME类型传输应用程序/八位字节流
Resource interpreted as Document but transferred with MIME type application/octet-stream
我坚持使用按钮,因为我看到的< a href ="url"下载>
可以完成这项工作.
I'm stuck to using a button as from what I've seen <a href="url" download>
will do the job.
关于如何解决这个问题的任何想法?
Any ideas on how this can be solved?
谢谢
推荐答案
请尝试如下操作:
window.open(url, '_blank')
这篇关于从按钮操作触发的角度下载外部zip文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!