Created
July 25, 2013 02:46
-
-
Save eperedo/6076503 to your computer and use it in GitHub Desktop.
Directive for ladda buttons
This file contains hidden or 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('buttonsApp').directive('ladda', ['$timeout', function ($timeout) { | |
return { | |
restrict: 'A', | |
scope: { | |
stop: '=stop' | |
}, | |
link: function postLink(scope, element, attrs) { | |
var l = Ladda.create(element[0]); | |
element.context.form.onsubmit = function(e) { | |
l.start(); | |
}; | |
scope.$watch('stop', function(newVal) { | |
if (angular.isDefined(newVal)) { | |
if (newVal) { | |
l.stop(); | |
} | |
} | |
}); | |
} | |
}; | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Checkout my fork (untested) which should be an easier to use implementation https://gist.github.com/ProLoser/6136208