Skip to content

Instantly share code, notes, and snippets.

@intellix
Created March 3, 2015 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save intellix/5c59ac148e089094275d to your computer and use it in GitHub Desktop.
Save intellix/5c59ac148e089094275d to your computer and use it in GitHub Desktop.
Thinking button in angular
'use strict';
angular.module('app.common').directive('btnThinking', function($compile) {
return {
restrict: 'A',
link: function (scope, element, attrs)
{
var html = element.html();
attrs.$observe('btnThinking', function(thinking) {
thinking = scope.$eval(thinking);
if (thinking) {
element.attr('disabled', true);
element.html('<i class="glyphicon glyphicon-refresh"></i>');
element.addClass('btn-thinking');
} else {
element.attr('disabled', false);
element.html(html);
$compile(element.contents())(scope);
element.removeClass('btn-thinking');
}
});
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment