I am trying to make a loader that will show on every page and fade out when all the content is loaded. Here is my code so far:
<div id="loader-wrapper" data-loader-drct data-ng-hide="hidden">
        <div id="loader"></div>
        <div class="loader-section section-left"></div>
        <div class="loader-section section-right"></div>
</div><!--end loader-wrapper-->
app.directive('loaderDrct', [function () {
        return {
            restrict: 'A',
            link: function (scope, element, attrs) {
                scope.$on('$routeChangeSuccess', function () {
                    var hide = false;
                    scope.hidden = hide;
                    scope.$on('$viewContentLoaded', function () {
                        hide = true;
                        scope.hidden = hide;
                    });
                });
            }
        }
}]);
When I execute this code, the loader is hiding (with some CSS added), but when I go to another page, the loader is not shown again. The ng-hide class is still there, which means that this directive has already been executed and did not refresh after going to the new page. 
How can I make the loader show and hide on every page?
 
     
     
     
    