frLadda.js
711 Bytes
/**
* A directive for super tiny implementation of Ladda.
*/
angular.module('fr.ladda', []).directive('frLadda', [function () {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var spinner;
scope.$watch(attrs.frLadda, function (newValue) {
if (newValue == true) {
spinner = angular.element('<span class="spinner"></span>');
element.append(spinner);
element.attr('disabled', 'disabled');
} else if (spinner) {
spinner.remove();
element.removeAttr('disabled');
}
});
},
};
}]);