title: AngularJS: need to fire event every time an ajax call is started
body: <p>I am trying to fire an event on $rootScope every time an ajax call is started.</p>
  
  <pre><code>var App = angular.module('MyApp');
  
  App.config(function ($httpProvider) {
      //add a transformRequest to preprocess request
      $httpProvider.defaults.transformRequest.push(function () {
          //resolving $rootScope manually since it's not possible to resolve instances in config blocks
          var $rootScope = angular.injector(['ng']).get('$rootScope');
          $rootScope.$broadcast('httpCallStarted');
  
         var $log = angular.injector(['ng']).get('$log');
         $log.log('httpCallStarted');
      });
  });
  </code></pre>
  
  <p>The event 'httpCallStarted' it's not being fired. I suspect that it's not correct to use $rootScope or any other instance service in config blocks. If so, how can I get an event everytime an http call is starting, without having to pass a config object in every time I am making a call?</p>
  
  <p>Thanks in advance</p>