angularjs ajax无刷新下载
Posted BaldWinf
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了angularjs ajax无刷新下载相关的知识,希望对你有一定的参考价值。
lb-statistics-filter-directive.html
<a class="btn btn-sm btn-primary" ng-click="downloadExcel(downloadUrl)" target="_blank" ng-class="'disabledEvent':!hasPreviewData">
lb-statistics-filter-directive.js
controller: function($scope,$http, $element, $attrs)
$scope.downloadExcel = function(downloadUrl)
console.log(downloadUrl)
$http.get(downloadUrl,
responseType: "arraybuffer",
timeout:600000
)
.success(function (data, status, headers, config)
var blob = new Blob([data], type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
var a = document.createElement("a");
document.body.appendChild(a)
a.download = $filter('date')(new Date(), 'yyyyMMddHHmmss') + ".xls";
a.href = URL.createObjectURL(blob);
a.click();
)
以上是关于angularjs ajax无刷新下载的主要内容,如果未能解决你的问题,请参考以下文章