Reputation: 4926
I am sending a downloadable file from backend to AngularJS. Whenever a GET request (with some data as parameters) is made to the "/report" url, the server sends a file that I want to receive in AngularJS. Ideally, a browser should prompt user for saving/opening a file that server sends. So far I have done this:
$scope.getReport = function () {
console.log("getReport");
var report_url = '/report';
var some_data = "asdf";
$http({method:'GET', url:report_url, data=some_data})
.success(function(data) {
});
};
Now I am unable to figure out how to get the file that server sent me.
Upvotes: 1
Views: 2088
Reputation: 1027
I created this fiddle for you http://jsfiddle.net/xMdQV/
Instead of making a get request and waiting for the server to return a file that you want to download
you could replace someData with your some_data
Tested on Chrome, Firefox and IE9.
Upvotes: 1