-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Why does $http outside of $apply actually work? #5206
Comments
@cburgdorf because it runs an |
It's not supposed to work like this. Can you point me to the code where it internally calls https://github.com/angular/angular.js/blob/master/src/ng/http.js#L226 And I can confirm that it actually needed to be called from within |
I believe they're referring to
https://github.com/angular/angular.js/blob/master/src/ng/http.js#L227 |
The $apply call takes place here, just after the request is finished : https://github.com/angular/angular.js/blob/master/src/ng/http.js#L991 But this is triggered after the $http call. the HTTP call itself wasnt triggered if called from outside Angular before 1.2.0. When using 1.1.5 in your plunk, the HTTP call is not even triggered so yes, something changed lately and i didnt find the revelant commit or explanation yet. good question :) |
@revolunet exactly. I also couldn't find a commit which should have changed it. Also the documentation says it shouldn't be that way. So I assume it has something to do with the |
my friend git bisect just told me that it comes from this commit : 6b91aa0 |
This makes it sound as if it's intended behavior in which we should remove the critical part from the documentation :) |
Well let's give @IgorMinar the chance to explain what's going on here :) |
This is intended behavior. 6b91aa0 was introduced to fix an issue with $http response interceptors. +1 for updating the docs (any volunteers?). |
Thanks for clarifying @btford |
This removes some outdated advice which no longer is true against the latest angular version. Relates to angular#5206
Done #5485 |
This removes some outdated advice which no longer is true against the latest angular version. The information about unit testing with ngMocks remains, because it's always good to have information like that easily found. This little snippet is not worded perfectly, and is not a very good example unit test, so additional work is needed here. Relates to #5206 Closes #5485
This removes some outdated advice which no longer is true against the latest angular version. The information about unit testing with ngMocks remains, because it's always good to have information like that easily found. This little snippet is not worded perfectly, and is not a very good example unit test, so additional work is needed here. Relates to angular#5206 Closes angular#5485
This removes some outdated advice which no longer is true against the latest angular version. The information about unit testing with ngMocks remains, because it's always good to have information like that easily found. This little snippet is not worded perfectly, and is not a very good example unit test, so additional work is needed here. Relates to angular#5206 Closes angular#5485
The documentation says that it should not work outside of $apply phase but yet it seems to work fine from outside of an $apply phase as proven by this plunkr:
http://plnkr.co/edit/2EXpWkYQuxCgPZ5x9JOu?p=preview
The text was updated successfully, but these errors were encountered: