1 app.directive('showDuringResolve', function($rootScope) {
2
3 return {
4 link: function(scope, element) {
5
6 element.addClass('ng-hide');
7 $rootScope.statechange = true;
8
9 var unregister = $rootScope.$on('$routeChangeStart', function() {
10 element.removeClass('ng-hide');
11 $rootScope.statechange = false;
12 });
13
14 scope.$on('$destroy', unregister);
15 }
16 };
17 });
18
1<div ng-view ng-show="statechange"></div>
2 <div ng-show="!statechange" show-during-resolve class="alert alert-info">
3 <strong>Loading.</strong>
4 Please hold.</div>
5