Angular: show loading bar on file upload

I am creating my first site using angular and I am facing the problem of how to show the loading bar on file upload.

  • The user clicks on the download link.
  • Client displays the message "Loading ..."
  • The client sends a request to the server to generate and return a file.
  • The server returns a dynamically generated file to the client
  • Client hides the "Loading ..." message
  • Client starts downloading 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 can i save file (data) using angular?

+3


source to share





All Articles