Created
March 3, 2015 12:50
-
-
Save intellix/5c59ac148e089094275d to your computer and use it in GitHub Desktop.
Thinking button in angular
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
'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