@@ -1031,7 +1031,7 @@ function $HttpProvider() {
1031
1031
</file>
1032
1032
</example>
1033
1033
*/
1034
- function $http ( requestConfig ) {
1034
+ function $http ( requestConfig , invokeApply ) {
1035
1035
1036
1036
if ( ! isObject ( requestConfig ) ) {
1037
1037
throw minErr ( '$http' ) ( 'badreq' , 'Http request configuration must be an object. Received: {0}' , requestConfig ) ;
@@ -1155,7 +1155,7 @@ function $HttpProvider() {
1155
1155
}
1156
1156
1157
1157
// send request
1158
- return sendReq ( config , reqData ) . then ( transformResponse , transformResponse ) ;
1158
+ return sendReq ( config , reqData , invokeApply ) . then ( transformResponse , transformResponse ) ;
1159
1159
}
1160
1160
1161
1161
function transformResponse ( response ) {
@@ -1318,7 +1318,7 @@ function $HttpProvider() {
1318
1318
1319
1319
function createShortMethods ( names ) {
1320
1320
forEach ( arguments , function ( name ) {
1321
- $http [ name ] = function ( url , config ) {
1321
+ $http [ name ] = function ( url , config , invokeApply ) {
1322
1322
return $http ( extend ( { } , config || { } , {
1323
1323
method : name ,
1324
1324
url : url
@@ -1330,7 +1330,7 @@ function $HttpProvider() {
1330
1330
1331
1331
function createShortMethodsWithData ( name ) {
1332
1332
forEach ( arguments , function ( name ) {
1333
- $http [ name ] = function ( url , data , config ) {
1333
+ $http [ name ] = function ( url , data , config , invokeApply ) {
1334
1334
return $http ( extend ( { } , config || { } , {
1335
1335
method : name ,
1336
1336
url : url ,
@@ -1347,7 +1347,7 @@ function $HttpProvider() {
1347
1347
* !!! ACCESSES CLOSURE VARS:
1348
1348
* $httpBackend, defaults, $log, $rootScope, defaultCache, $http.pendingRequests
1349
1349
*/
1350
- function sendReq ( config , reqData ) {
1350
+ function sendReq ( config , reqData , invokeApply ) {
1351
1351
var deferred = $q . defer ( ) ,
1352
1352
promise = deferred . promise ,
1353
1353
cache ,
@@ -1465,11 +1465,16 @@ function $HttpProvider() {
1465
1465
resolvePromise ( response , status , headersString , statusText , xhrStatus ) ;
1466
1466
}
1467
1467
1468
- if ( useApplyAsync ) {
1469
- $rootScope . $applyAsync ( resolveHttpPromise ) ;
1468
+ var skipApply = ( isDefined ( invokeApply ) && ! invokeApply ) ;
1469
+ if ( ! skipApply ) {
1470
+ if ( useApplyAsync ) {
1471
+ $rootScope . $applyAsync ( resolveHttpPromise ) ;
1472
+ } else {
1473
+ resolveHttpPromise ( ) ;
1474
+ if ( ! $rootScope . $$phase ) $rootScope . $apply ( ) ;
1475
+ }
1470
1476
} else {
1471
1477
resolveHttpPromise ( ) ;
1472
- if ( ! $rootScope . $$phase ) $rootScope . $apply ( ) ;
1473
1478
}
1474
1479
}
1475
1480
0 commit comments