Search code examples
javascripthttpangularjsprogress

Find the download status of an http get request in progress using Angular.js


I've searched all over the web and can't seem to find anything that says, one way or the other, whether or not I can get the status of downloading data during an $http.get request. The application I'm writing regularly downloads a lot of data which can take up to 30 seconds. Rather than display an animated loading gif, I would like to display a progress bar which shows the status of how much of the data has downloaded. I am using Angular.js and this is what my get request looks like.

$http.get(<apiURL>).success(function(data,status,headers,config){
    $scope.data = data;
});

On the success of the request I populate my page with the data. Is there some way to, in the time it's fetching that data from the server, to constantly read the download status?


Solution

  • I found a fantastic library to use in order to achieve what I wanted without having to change the back-end server code. It's a Github project called Angular Loading Bar. Simply bower or npm install and it automatically works on your http requests with Angular. Excellent library.