mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
feat($http): broadcast $http.request event
This commit is contained in:
parent
a4c8ac7126
commit
7b705df2b7
2 changed files with 11 additions and 0 deletions
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue