我想在angularjs
按钮上下载文件 <button ng-click=downloadfile()>download</button>
在控制器中
$scope.downloadfile=function()
{
//
}
我必须在downloadfile函数中编写哪些功能,请您解释
答案 0 :(得分:5)
在downloadFile()
函数中写出来。
//Initialize file format you want csv or xls
var uri = 'data:text/csv;charset=utf-8,' + escape(CSV);
//this trick will generate a temp <a /> tag
var link = document.createElement("a");
link.href = uri;
//set the visibility hidden so it will not effect on your web-layout
link.style = "visibility:hidden";
link.download = fileName + ".csv"; //this is an example file to download, use yours
//this part will append the anchor tag and remove it after automatic click
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
答案 1 :(得分:0)
$ scope.downloadFile = function(doc){
ConcurrentHashMap<Integer,String> cmap = new ConcurrentHashMap<> ();
cmap.computeIfAbsent (1, e-> {cmap.remove (1); return "x";});