Skip to content

Instantly share code, notes, and snippets.

@matiasfha
Last active November 13, 2015 13:52
Show Gist options
  • Select an option

  • Save matiasfha/ac24c76a426285184b5b to your computer and use it in GitHub Desktop.

Select an option

Save matiasfha/ac24c76a426285184b5b to your computer and use it in GitHub Desktop.
Route loader directive
function routeLoaderCtrl ($rootScope) {
$rootScope.$on('$routeChangeStart', function (){
this.routeLoading = true;
}.bind(this));
$rootScope.$on('$routeChangeSuccess', function (){
this.routeLoading = false;
}.bind(this));
}
function routeLoaderDirective () {
return {
restrict: 'E',
templateUrl: 'route-loader.html',
controller: 'routeLoaderCtrl',
controllerAs: 'vm',
scope: {},
bindToController: {
routeLoading:'='
}
}
}
angular
.module('core')
.controller('routeLoaderCtrl', routeLoaderCtrl)
.directive('routeLoader',routeLoaderDirective);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment