$scope.download = function () { |
| | AttachmentService.download().success(function (data) { |
| | var filename = $stateParams.type + $stateParams.id + '.zip'; |
| | var blob = new Blob([data], { type: "application/zip" }); |
| | var URL = window.URL || window.webkitURL || window; |
| | var link = document.createElement('a'); |
| | link.href = URL.createObjectURL(blob); |
| | link.download = filename; |
| | var event = document.createEvent('MouseEvents'); |
| | event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); |
| | link.dispatchEvent(event); |
| |
h5 a标签的download属性支持chorme和firefox,建议找个插件(fileSaver.js),或者用后端下载,用后端的链接直接下载