title: Angular JS: $location injection undefined
body: <p>I'm trying to configure my route in such a way to redirect to the login page if user is not logged. This is my code:</p>
  
  <pre><code>angular.module('witBiz.services', []);
  angular.module('witBiz.controllers', ['witBiz.services']);
  var witBizModule = angular.module('witBiz', ['ngRoute' , 'witBiz.controllers', 'witBiz.services'   ]);
  
  witBizModule.config(['$routeProvider', function($routeProvider) {
      $routeProvider.when('/login', {templateUrl: 'resources/views/login.html', controller: 'LoginController'});
      $routeProvider.when('/index', {templateUrl: 'resources/views/index.html', controller: 'IndexController'});
      $routeProvider.otherwise({redirectTo: 'resources/views/index.html'});
  }])
      .run(['$rootScope',  'checkLogin', function($rootScope, checkLogin ,$routeProvider ) {
          $rootScope.$on('$routeChangeSuccess', function () {
             if (checkLogin())
                  $location.url("/index");
          })
      }])
      .factory('checkLogin', function(){
          return function() {
              //perform real logic here
              return true;
          }
      })
  </code></pre>
  
  <p>where basically I declare modules and services. Now the problem is $location is not defined so I get error.
  I tried to inject $location as dependency like this but I got undefined injection (injpt):</p>
  
  <pre><code>.run(['$rootScope',  'checkLogin', '$location', function($rootScope, checkLogin ,$location) {
          $rootScope.$on('$routeChangeSuccess', function () {
             if (checkLogin())
                  $location.url("/ciao");
          })
      }])
  </code></pre>
  
  <p>So I'm wondering how I can use the builtin $location services inside my "run" method...why can I inject it as a dependency as $rootScope or checkLogin?!</p>
  
  <p>I'm using angular 1.2.0 rc2.</p>
  
  <p>Thanks</p>