diff options
| author | Vojta Jina | 2011-10-31 12:03:09 -0700 | 
|---|---|---|
| committer | Igor Minar | 2011-11-30 11:17:23 -0500 | 
| commit | 7b705df2b77bbd5e112b976a7a9630327aa77aca (patch) | |
| tree | 55441469b87309ff324676ddc2426ed930e8f3a2 | |
| parent | a4c8ac7126aab33ac0d8296a7495475363a0ea9b (diff) | |
| download | angular.js-7b705df2b77bbd5e112b976a7a9630327aa77aca.tar.bz2 | |
feat($http): broadcast $http.request event
| -rw-r--r-- | src/service/http.js | 1 | ||||
| -rw-r--r-- | test/service/httpSpec.js | 10 | 
2 files changed, 11 insertions, 0 deletions
| diff --git a/src/service/http.js b/src/service/http.js index 92b95f35..23f33fad 100644 --- a/src/service/http.js +++ b/src/service/http.js @@ -343,6 +343,7 @@ function $HttpProvider() {          rawRequest = $httpBackend(cfg.method, cfg.url, data, done, headers, cfg.timeout);        } +      $rootScope.$broadcast('$http.request', self);        $http.pendingRequests.push(self);        return this;      }; diff --git a/test/service/httpSpec.js b/test/service/httpSpec.js index 11165adc..12921992 100644 --- a/test/service/httpSpec.js +++ b/test/service/httpSpec.js @@ -686,6 +686,16 @@ describe('$http', function() {    }); +  it('should broadcast $http.request', function() { +    $httpBackend.when('GET').then(200); +    scope.$on('$http.request', callback); +    var xhrFuture = $http({method: 'GET', url: '/whatever'}); + +    expect(callback).toHaveBeenCalledOnce(); +    expect(callback.mostRecentCall.args[1]).toBe(xhrFuture); +  }); + +    describe('transform', function() {      describe('request', function() { | 
