Cancel $routeChangeStart event...

Showing 1-3 of 3 messages
Cancel $routeChangeStart event... Vili 11/27/12 2:29 AM
Hi All,

I am listening $routeChangeStart event while view change.... ($rootScope) {
    $rootScope.$on('$routeChangeStart', function (event, scope, newRoute) {
       if(Some Condition){
         //code to stop $routeChangeStart


I want to stop the $routeChangeStart event.
Re: Cancel $routeChangeStart event... Björn Weinbrenner 12/14/12 8:43 AM
Re: Cancel $routeChangeStart event... Anderson Aroeira Araujo 12/22/12 2:54 PM
Hi Vili,

You can cancel the event.
I have implemented a solution like this:

$scope.hasChanges = function () {
return false;
var blockNavigation = true;
$scope.$on('$locationChangeStart', function(event, next, current) {
          if ($scope.hasChanges() & blockNavigation) {
                'Are you sure?', 
                {'YES': function() {
                    blockNavigation = false;
                  'NO': function(){MessageService.clear(); $log.log('NO Selected')}});