AngularJS - Receive and download CSV

前端 未结 5 908
醉酒成梦
醉酒成梦 2020-12-11 17:11

I am using a nodeJS program as a server and an AngularJS web application as the client.

To create the CSV I\'m using the \"express-csv\" library (https://www.npmjs.c

5条回答
  •  暖寄归人
    2020-12-11 17:22

    You can create a tag and click on it:

        $http.get("http://"+$localStorage.ip+":"+$localStorage.port+"/exportDB").success(function(response) {
            var dataURI = 'data:application/octet-stream;base64,' + btoa(response);
            $('').attr({
                download:  'db.csv',
                href: dataURI
            })[0].click();
        });
    

提交回复
热议问题