aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Burgdorf2013-12-19 20:48:43 +0100
committerCaitlin Potter2014-01-18 22:52:58 -0500
commit6c9131ef10377e096c178d378666bc7fc2919f09 (patch)
tree81cb647bf2e0642a0bfa43bb219810cdeeac9b10
parent99c5027bf26fa1e14611eb38b8ad9d0197784897 (diff)
downloadangular.js-6c9131ef10377e096c178d378666bc7fc2919f09.tar.bz2
docs($http): remove outdated part about $http outside of $apply phase
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
-rw-r--r--src/ng/http.js25
1 files changed, 4 insertions, 21 deletions
diff --git a/src/ng/http.js b/src/ng/http.js
index 4ca89e4f..f20d54fd 100644
--- a/src/ng/http.js
+++ b/src/ng/http.js
@@ -223,31 +223,14 @@ function $HttpProvider() {
* XMLHttpRequest will transparently follow it, meaning that the error callback will not be
* called for such responses.
*
- * # Calling $http from outside AngularJS
- * The `$http` service will not actually send the request until the next `$digest()` is
- * executed. Normally this is not an issue, since almost all the time your call to `$http` will
- * be from within a `$apply()` block.
- * If you are calling `$http` from outside Angular, then you should wrap it in a call to
- * `$apply` to cause a $digest to occur and also to handle errors in the block correctly.
- *
- * ```
- * $scope.$apply(function() {
- * $http(...);
- * });
- * ```
- *
* # Writing Unit Tests that use $http
- * When unit testing you are mostly responsible for scheduling the `$digest` cycle. If you do
- * not trigger a `$digest` before calling `$httpBackend.flush()` then the request will not have
- * been made and `$httpBackend.expect(...)` expectations will fail. The solution is to run the
- * code that calls the `$http()` method inside a $apply block as explained in the previous
- * section.
+ * When unit testing (using {@link api/ngMock ngMock}), it is necessary to call
+ * {@link api/ngMock.$httpBackend#methods_flush $httpBackend.flush()} to flush each pending
+ * request using trained responses.
*
* ```
* $httpBackend.expectGET(...);
- * $scope.$apply(function() {
- * $http.get(...);
- * });
+ * $http.get(...);
* $httpBackend.flush();
* ```
*