angualr js busy when routing code example

Example 1: angualr js busy when routing

app.directive('showDuringResolve', function($rootScope) {

      return {
         link: function(scope, element) {

              element.addClass('ng-hide');
              $rootScope.statechange =  true;

             var unregister = $rootScope.$on('$routeChangeStart', function() {
                element.removeClass('ng-hide');
                   $rootScope.statechange =  false;
            });

            scope.$on('$destroy', unregister);
          }
       };
     });

Example 2: angualr js busy when routing

<div ng-view ng-show="statechange"></div>
  <div ng-show="!statechange" show-during-resolve class="alert alert-info">
      <strong>Loading.</strong>
      Please hold.</div>