Duplia App Duplia App - 1 year ago 537
Javascript Question

Angular 1.5.4 $http progress event

Now Angular 1.5.4 finally allows you to track progress event on $http provider but for some reason I keep getting the $rootScope as a response instead of an actual progress (I'm using it for uploads) information. Because of lack of examples I found some tests in the Angular repo and followed that but to no success.

restClientInstance.post = function (requestParams) {
var postParams = {
method: "POST",
url: API_URL + requestParams.url,
headers: requestParams.headers,
data: requestParams.data,
eventHandlers: {
progress: function (c) {
uploadEventHandlers: {
progress: function (e) {

var promise = $http(postParams)
return promise;

In both cases it consoles $rootScope rather than the lengthComputable

Answer Source

Well I ended up doing something like this and just handle it myself as the XHR events added to $http dont work for me.

var xhttp = new XMLHttpRequest();
var promise = $q.defer();

xhttp.upload.addEventListener("progress",function (e) {
xhttp.upload.addEventListener("load",function (e) {
xhttp.upload.addEventListener("error",function (e) {

xhttp.open("post",API_URL + requestParams.url,true);


return promise.promise;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download