1

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.

1

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.