You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
$http eventHandlers return $rootScope rather than actual XHR event 1.5.4 #14436
Do you want to request a feature or report a bug? BUG
What is the current behavior?
eventHandlers:{"progress":function (e) {
console.log(e);
}},
uploadEventHandlers: {"progress": function (e) {
console.log(e);
}}
console.log responds with $rootScope
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (template: http://plnkr.co/edit/tpl:yBpEi4).
attach event handlers for progress to $http post call that uploads a file to the server
upload the file and try to listen for progress info none of the progress information is being passed.
What is the expected behavior?
console.log would return the actual xhr event not $rootScope
What is the motivation / use case for changing the behavior?
I have been waiting 2 years for Angular to track the "progress" event and it still cant get it right?!?!
Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.
1.5.4 all major browsers Mac and PC
Other information (e.g. stacktraces, related issues, suggestions how to fix)
@ghost, this feture was obviously not in development for two years - being in the backlog and low-priority and being in development are not the same thing.
(I hope we wouldn't need 2 years of active development to complete that feature 😃)
That said, if there is a bug, we should totally fix it. Thx for reporting it 👍
I was very excited when I saw the 1.5.4 release, i check the releases almost every day for this feature since my post #11547 (comment) at #11547 (the PR was opened in Apr 11, 2015)
It also includes a workaround (it is an hack, but you can't just rewrite token refreshing mechanism, based on custom wrapper around $http, to get around of this hack, can you?).
Here is the beauty of the hack: you can't archive something like this via $http without the hack
@songbaoqiang We can add 1.5.10 to the list. eventHandlers and uploadEventHandlers are never triggered. Thus the need for a PR to fix it is still relevant to this day.
Activity
Narretz commentedon Apr 14, 2016
What kind of attitude is that? See it like this, you had 2 years to provide a PR.
gkalpak commentedon Apr 14, 2016
@ghost, this feture was obviously not in development for two years - being in the backlog and low-priority and being in development are not the same thing.
(I hope we wouldn't need 2 years of active development to complete that feature 😃)
That said, if there is a bug, we should totally fix it. Thx for reporting it 👍
fix($http): pass event object to `eventHandlers`/`uploadEventHandlers`
buraktamturk commentedon Apr 14, 2016
I was very excited when I saw the 1.5.4 release, i check the releases almost every day for this feature since my post #11547 (comment) at #11547 (the PR was opened in Apr 11, 2015)
It also includes a workaround (it is an hack, but you can't just rewrite token refreshing mechanism, based on custom wrapper around $http, to get around of this hack, can you?).
Here is the beauty of the hack: you can't archive something like this via $http without the hack

gkalpak commentedon Apr 14, 2016
Well. there's a PR with a fix in place (#14438), it should be fine by the time
v1.5.5is out 😃fix($http): pass event object to `eventHandlers`/`uploadEventHandlers`
petebacondarwin commentedon Apr 15, 2016
Hopefully that will fix this wrinkle :-) 21 hours is a bit better than 2 years, eh?
buraktamturk commentedon Apr 15, 2016
we'll wait for the 1.5.5 anyway :D
petebacondarwin commentedon Apr 15, 2016
Thank you for your patience @buraktamturk - it is a virtue I am told :-)
songbaoqiang commentedon Sep 13, 2016
eventHandlers:{"progress":function (e) {
console.log(e);
}},
uploadEventHandlers: {"progress": function (e) {
console.log(e);
}}
are not fired in 1.5.5 1.5.6 1.5.7 15.8
buraktamturk commentedon Sep 13, 2016
@songbaoqiang Could you provide an example? I am sure that the upload event thing works on my projects.
songbaoqiang commentedon Sep 13, 2016
html
<script src="//cdn.bootcss.com/angular.js/1.5.5/angular.min.js"></script>Please choose your file
js
var FMApp = angular.module('FMApp', ['ur.file']);
FMApp.controller('FileManagerCtr', ['$scope', '$http', '$location','$q',
function ($scope, $http, $location,$q) {
var FM = this;
.........
var canceller = $q.defer();
FM.upload = function () {
console.log('Upload File:', FM.uploadFile);
var formData = new FormData();
formData.append('upload', FM.uploadFile);
var myurl = 'api' + FM.curFolderPath + FM.uploadFile.name;
};
jbouhier commentedon Feb 9, 2017
@songbaoqiang We can add 1.5.10 to the list. eventHandlers and uploadEventHandlers are never triggered. Thus the need for a PR to fix it is still relevant to this day.
fix($http): pass event object to `eventHandlers`/`uploadEventHandlers`