小编Kom*_*ngh的帖子

从Angular中的服务器下载text/csv内容,而不是在Mozilla FireFox中工作

从Angular中的服务器下载text/csv内容作为文件

回答者 - /sf/users/144494451/

$http({method: 'GET', url: '/someUrl'}).
  success(function(data, status, headers, config) {
     var anchor = angular.element('<a/>');
     anchor.attr({
         href: 'data:attachment/csv;charset=utf-8,' + encodeURI(data),
         target: '_blank',
         download: 'filename.csv'
     })[0].click();

  }).
  error(function(data, status, headers, config) {
    // if there's an error you should see it here
  });
Run Code Online (Sandbox Code Playgroud)

我实现了这个解决方案,使用angular从服务器下载文件到客户端.这在Google Chrome中完美运行.但是这个解决方案在Mozilla Firefox中不起作用.

谢谢

javascript csv firefox node.js angularjs

4
推荐指数
1
解决办法
3015
查看次数

标签 统计

angularjs ×1

csv ×1

firefox ×1

javascript ×1

node.js ×1