0

I am returning a .csv file from my python/tornado backend.

for line in csv_lines:
    self.write(line + '\n')
self.set_header('Content-type', 'text/csv')

Here is my current (angular) frontend

$scope.exportCsv = function() { 
    var route = _mkRoute();
    window.open(route);
}

However, this was a bit of a workaround... I would prefer to do something like this.

$http.get(route).then(
    function(response) {
        // launch the download dialog box
    },
    function(error) {
        // some error handling
    }
);

However, no dialog box pops up when I use this approach.

Is there an "angular" way to launch a download dialog box after the request completes? I would have googled, but it was a bit hard for me to phrase this into a google-able term.

Thanks!

Zack
  • 13,454
  • 24
  • 75
  • 113
  • Some plunker example would be helpful to understand the problem. Would you like to provide possibility of downloading something related to the get response? Actually there should be no problem to provide download on success as in your last section – ciekawy Feb 22 '16 at 17:38
  • 1
    Not really possible. See http://stackoverflow.com/questions/3346072/download-csv-file-using-ajax Workaround is to use a hidden iframe. – Sergiu Paraschiv Feb 22 '16 at 18:14

0 Answers0