Simple angular directive which prevents users from repeatedly clicking a button.
- Using bower and running
bower install ib-submit
#How to add to the project
<script type="text/javascript" src="../bower_components/ib-submit/ib-submit.js"></script>
angular.module('app', ['ib-submit']);
#Code example Your function must return promise!
$scope.sendData = function() {
return sendData($scope.formData).then(function(res) {
$scope.formData = {};
});
};
function sendData(data) {
var deferred = $q.defer();
deferred.resolve(data);
return deferred.promise;
}
##HTML
<button
ib-submit
after-submit-text="Button Text"
submit-action="sendData()"
>Submit
</button>