title: AngularJs - cancel route change event
body: <p>How do I cancel route change event in AngularJs?</p>
  
  <p>My current code is</p>
  
  <pre><code>$rootScope.$on("$routeChangeStart", function (event, next, current) {
  
  // do some validation checks
  if(validation checks fails){
  
      console.log("validation failed");
  
      window.history.back(); // Cancel Route Change and stay on current page  
  
  }
  });
  </code></pre>
  
  <p>with this even if the validation fails Angular pulls the next template and associated data and then immediately switches back to previous view/route. I don't want angular to pull next template &amp; data if validation fails, ideally there should be no window.history.back(). I even tried event.preventDefault() but no use.</p>