title: Circular dependency found: $http <- $templateFactory <- $view <- $state
body: <p>I have a current 401 check that I'm running with $location which is working fine.  However I'd like to swap it over to $state and use ui-router instead.  When I do so i get an error code as:</p>
  
  <pre><code>Circular dependency found: $http &lt;- $templateFactory &lt;- $view &lt;- $state &lt;- authHttpResponseInterceptor &lt;- $http &lt;- $compile
  </code></pre>
  
  <p>My currently code looks fine as I check certain paths and allow no logged in users to view them:</p>
  
  <pre><code>  /* Look for 401 auth errors and then redirect */
    .factory('authHttpResponseInterceptor',['$q','$location', function($q,$location) {
  
        return {
            response: function(response){
                if (response.status === 401) {
                }
  
                return response || $q.when(response);
            },
            responseError: function(rejection) {
                var reservedPaths = ['/','/login','/connect','/event'];
                if (rejection.status === 401 &amp;&amp; _.contains(reservedPaths,$location.path().trim())) {
                    $location.path('/welcome');
  
                }
                return $q.reject(rejection);
            }
        };
    }])
    .config(['$httpProvider',function($httpProvider) {
        //Http Intercpetor to check auth failures for xhr requests
        $httpProvider.interceptors.push('authHttpResponseInterceptor');
    }]);
  </code></pre>
  
  <p>The code I added is as follows.:</p>
  
  <pre><code>  /* Look for 401 auth errors and then redirect */
    .factory('authHttpResponseInterceptor',['$q','$location', **'$state',** function($q,$location, **$state**) {
  
        return {
            response: function(response){
                if (response.status === 401) {
                }
  
                return response || $q.when(response);
            },
            responseError: function(rejection) {
                var reservedPaths = ['/','/mycube','/connect','/event'];
                if (rejection.status === 401 &amp;&amp; _.contains(reservedPaths,$location.path().trim())) {
                    **$state.go('home');**
  
                }
                return $q.reject(rejection);
            }
        };
    }])
    .config(['$httpProvider',function($httpProvider) {
        //Http Intercpetor to check auth failures for xhr requests
        $httpProvider.interceptors.push('authHttpResponseInterceptor');
    }]);
  </code></pre>
  
  <p>Why would adding state cause this issue when it works fine with location? </p>