title: Angular get route parameters from location change start
body: <p>I have routes setup like so:</p>
  
  <pre><code>app.config(function($routeProvider) {
  
    $routeProvider
  
    //login
    .when("/", {
      templateUrl : "framework/views/login.html",
      controller  : "LoginCtrl",
      title: "Login",
      authenticate: false
    })
  
    //dashboard
   .when("/dashboard", {
      templateUrl : "framework/views/dashboard.html",
      controller  : "DashboardCtrl",
      title: "Dashboard",
      authenticate: true
    });
  });
  </code></pre>
  
  <p>Now I want to redirect location changes if <code>authenticate</code> is set to <code>true</code> on the route but a <code>session variable</code> is not <code>true</code>.</p>
  
  <p>For example:</p>
  
  <pre><code>$rootScope.$on("$locationChangeStart", function(event, newURL, oldURL){ 
    if (toState.authenticate &amp;&amp; $window.sessionStorage.isLoggedIn) {
      $location.path("/");
    }
  });
  </code></pre>
  
  <p>This works if I use <code>$routeChangeStart</code> instead, but then I see the next route briefly before it redirects. Location change seems to stop that, but I can't work out how to access the route parameters (i.e. the authenticate parameter).</p>
  
  <p>How do I do this? Or is there a better way entirely?</p>