title: How to get resovled value from $routeProvider in AngularJS?
body: <p>On change of views in my application i  created resolve function which should find out if user is logged in or not:         </p>
  
  <pre><code>   $routeProvider.
              when('/taskoverview', {
                  templateUrl: 'Home/Template/taskoverview', resolve: TaskOverviewCtrl.resolve, access: { allowAnonymous: true },
                  resolve: {
                      userAuthenticated: ["$http", function ($http) {
                          var loggedIn;
                          $http.get('/api/Authentication/UserAuthenticated').then(function (data) {
                              if (data.data != null) {
                                  loggedIn = true;
                              }
                              else {
                                  loggedIn = false;
                                  console.log("really");
                              }   
                          });
                          return loggedIn;
  
                      }]
                  }
              }).
              otherwise({ redirectTo: '/' });
  </code></pre>
  
  <p>After it happend i want to check value of userAuthenticated on locationChangeStart, so i thought it should be pretty much straign forward.</p>
  
  <pre><code>WorkerApp.run(function ($rootScope, $routeParams, $route, $location) {
          $rootScope.$on('$locationChangeStart', function (event, next, current) {
              for (var i in $route.routes) {
                  if (next.indexOf(i) != -1) {
                      if ($route.routes[i].access != null &amp;&amp; ($route.routes[i].userAuthenticated != null || typeof($route.routes[i].userAuthenticated) != "undefined")) {
                              if ((!$route.routes[i].access.allowAnonymous || $route.routes[i].access.allowAnonymous == "undefined") &amp;&amp; (!$route.routes[i].userAuthenticated || $route.routes[i].userAuthenticated == "undefined")) {
                                  event.preventDefault();
                                  alert("no access");
  
                              }
                          }
                      }
                  }
  
          });
  
      });
  </code></pre>
  
  <p>But evrytime i change my userAuthenticated is always undefined. So question is, how do i make it return a value? </p>
  
  <p>Are there any more straigh way to prevent user to access pages without authenticated? </p>