Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 16c7ab1

Browse files
wakandanpetebacondarwin
authored andcommitted
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.
1 parent 9ef5d8f commit 16c7ab1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/ng/http.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,10 @@ function $HttpProvider() {
185185
* will result in the success callback being called. Note that if the response is a redirect,
186186
* XMLHttpRequest will transparently follow it, meaning that the error callback will not be
187187
* called for such responses.
188+
*
189+
* If your $http is scheduled from something that doesn't cause a $digest to fire then your
190+
* request won't be sent immediately. To make sure a $http request if fired immediately, wrap your
191+
* call around with an $scope.$apply(function(){ //make $http request here }
188192
*
189193
* # Shortcut methods
190194
*

0 commit comments

Comments
 (0)