title: Redirect user to home page if type not existing url
body: <p>I need to redirect "logged in" user to home page if user type not existing url. I have a service named "authService" where I can check if <code>user auth ==  true</code> or <code>false</code>.</p>
  
  <p>I use <code>$STATE.GO</code> to redirect to login page if user is not auth ( <code>authService.auth == false</code>). </p>
  
  <pre><code>app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', '$httpProvider',
  function ($stateProvider, $urlRouterProvider, $locationProvider) {
   $urlRouterProvider.otherwise(function ($injector, $location) {
  
          var $state = $injector.get("$state");
          $state.go("login");
      });
  }]);
  </code></pre>
  
  <p>Now I want to make similar to redirect user to home page, when user is <code>auth == true</code>. When user with token, try to type not existing url, redirect to home page. </p>
  
  <p>I try to do this with inject authService service and make if/else. 
  But this isn't working because I get an error</p>
  
  <blockquote>
    <p>Error: $injector:unpr
    Unknown Provider
    Unknown provider: authService</p>
  </blockquote>
  
  <pre><code> app.config(['$stateProvider', '$urlRouterProvider', '$locationProvider', '$httpProvider', 'authService',
  function ($stateProvider, $urlRouterProvider, $locationProvider, authService) {
   if (authService.auth == false) {
      $urlRouterProvider.otherwise(function ($injector, $location) {
  
          var $state = $injector.get("$state");
          $state.go("login");
      });
      }
  else {
     $urlRouterProvider.otherwise(function ($injector, $location) {
  
          var $state = $injector.get("$state");
          $state.go("home");
      });
  
   }
  }]);
  </code></pre>
  
  <p>Is this bad solution? Can I inject custom service to app.config? Can someone pls help me? </p>
  
  <p>Thank you.</p>