Created
July 6, 2015 11:35
-
-
Save pascalwhoop/e5f07c3711fe4b3014ca to your computer and use it in GitHub Desktop.
wait-bar directive for angular material design. Shows wait bar once showEvent is emitted on rootScope and hides it again once hideEvent is emitted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @ngdoc directive | |
* @name frontendApp.directive:equals | |
* @description | |
* A directive to show and hide a loading bar. it takes two attributes (show-event and hide-event) which must be the event names it should listen on on the rootScope. | |
*/ | |
.directive('waitBar', ['$rootScope', function ($rootScope) { | |
return { | |
restrict: 'E', // only activate on element attribute | |
link: function (scope, elem, attrs) { | |
scope.visible = false; | |
scope.message = attrs.message; | |
// watch own value and re-validate on change | |
$rootScope.$on(attrs.showEvent, function () { | |
scope.visible = true; | |
}); | |
$rootScope.$on(attrs.hideEvent, function () { | |
scope.visible = false; | |
}); | |
}, | |
template: '<div ng-show="visible"><p>{{message}}</p></p><md-progress-linear md-mode="indeterminate" flex></md-progress-linear></div>' | |
} | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment