title: Angular JS $locationChangeStart get next url route object
body: <p>I am trying to implement Authorization on my angular application, when a route is changed I want to check whether the route is authorized for user or not. I tried with <code>$routeChangeStart</code> but it does not prevents the event.</p>
  
  <p>My current code:</p>
  
  <pre><code>$scope.$on('$routeChangeStart', function(event, next, current) {
          if(current_user.is_logged_in){
              var route_object = next.route_object;
              if(!(route_object.route_roles)){
                  event.preventDefault();
              }
          }
      });
  </code></pre>
  
  <p>Here in my <code>next</code> object I am getting route_object which is set in my <code>$routeProvider</code></p>
  
  <pre><code>var routes = object;
      app.config(function($routeProvider) {
                  $routeProvider.when(url, {
                      templateUrl: "/users.html",
                      route_object: routes,
                      });
              });
  </code></pre>
  
  <p><code>routes</code> is an object which is formed in my function, but when I use <code>$locationChangeStart</code> I am just getting url's of next and previous page,</p>
  
  <p>How do I get the entire route object??</p>