download csv file from web api in angular js

Try it like :

File.save(csvInput, function (content) {
    var hiddenElement = document.createElement('a');

    hiddenElement.href="https://stackoverflow.com/questions/20300547/data:attachment/csv," + encodeURI(content);
    hiddenElement.target="_blank";
    hiddenElement.download = 'myFile.csv';
    hiddenElement.click();
});

based on the most excellent answer in this question

Leave a Comment