Download file from GET response

时间:2015-10-06 08:46:00

标签: angularjs asp.net-web-api ngresource

In my Angular app, I'm using ngResource to send a GET request to a WebAPI server. It simply looks like this:

vm.exportCSV = function() {
    languageResource.export(function(data) {

    });
}

The server returns a response with the header Content-Type: text/csv and content like this:

Key;Language;Value
1;Enlish;Blabla
2;German;blabla

I have added ng-click='vm.exportCSV' to a link, and want to download the file returned by the request when clicked. I tried to do it like suggested here, but this simply gives me a file containing [object Object].

How can I accomplish this?

0 个答案:

没有答案