Advertisement
Guest User

Untitled

a guest
Jul 30th, 2015
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. "use strict";
  2.  
  3. /**
  4. * Show loading progress in button
  5. * Usage : <button class="btn-progress">Async call</button>
  6. * Note : $parent controller must define a $loading variable to apply effect
  7. */
  8. angular.module('btnProgress', [])
  9.  
  10. .directive('btnProgress', function () {
  11. return {
  12. restrict: 'C',
  13. scope: false,
  14.  
  15. template: function (element) {
  16. return element[0].innerText + ' <i class="fa fa-circle-o-notch fa-spin" ng-if="$loading"></i>';
  17. },
  18.  
  19. link: function (scope, element) {
  20.  
  21. scope.$watch('$loading', function (isLoading) {
  22. if (angular.isDefined(isLoading))
  23. toggleDisabled();
  24. });
  25.  
  26. function toggleDisabled() {
  27. element[0].disabled = !element[0].disabled;
  28. }
  29. }
  30. }
  31. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement