docs($http): explain why $http may not make the request immediately

I came across this issue today and after researching has found out this thread on so:
http://stackoverflow.com/questions/17039998/angular-not-making-http-requests-immediately.

It took me quite sometimes to figure out this so I hope the addition in documentation could save somebody else some times and frustration.
This commit is contained in:
Dang Nguyen Anh Khoa 2013-09-13 18:36:27 +08:00 committed by Pete Bacon Darwin
parent aa3c54c73f
commit b15686cb79

View file

@ -222,6 +222,10 @@ function $HttpProvider() {
* XMLHttpRequest will transparently follow it, meaning that the error callback will not be * XMLHttpRequest will transparently follow it, meaning that the error callback will not be
* called for such responses. * called for such responses.
* *
* If your $http is scheduled from something that doesn't cause a $digest to fire then your
* request won't be sent immediately. To make sure a $http request if fired immediately, wrap your
* call around with an $scope.$apply(function(){ //make $http request here }
*
* # Shortcut methods * # Shortcut methods
* *
* Since all invocations of the $http service require passing in an HTTP method and URL, and * Since all invocations of the $http service require passing in an HTTP method and URL, and