3

i am building my first site using angular and i encountered a problem of how to show loading bar when downloading a file.

  1. User clicks on a download link
  2. Client displays a "Loading..." message
  3. Client sends a request to server for generating and returning the file.
  4. Server returns the dynamically generated file to the client
  5. Client hides the "Loading..." message
  6. Client starts to download the file

I tried:

 $scope.download= function () {
        $scope.showLoading = true; 
        var url = 'http://localhost:9000/download?file=myfile';

        $http.get(url).success(function (data) {
            $scope.showLoading = false;
            // what to do with data(file)?
        });              
    }

how I can save the the file(data) using angular?

Eitan F
  • 31
  • 2
  • This might help: http://stackoverflow.com/questions/24080018/download-file-from-a-webapi-method-using-angularjs – MichaelLo Oct 17 '14 at 20:07
  • Well, what do you actually want to do with your data? You can just put it in your scope, or return it via a callback, or even return the $http promise to deal with it later. Please give us more details – floribon Oct 17 '14 at 21:12
  • the data response is the file I want to download, the file should be downloaded to the clients computer – Eitan F Oct 18 '14 at 10:21

0 Answers0