vormjs
Version:
Write your forms in JSON and HTML, use the same API.
29 lines (20 loc) • 515 B
JavaScript
/*global angular*/
(function ( ) {
angular.module('vorm')
.directive('vormSubmit', [ '$parse', function ( $parse ) {
return {
require: [ 'vormForm' ],
link: function ( scope, element, attrs, controllers ) {
const [ vorm ] = controllers;
let cb;
function handleSubmit ( ) {
cb(scope, {
$values: vorm.getValues()
});
}
cb = $parse(attrs.vormSubmit);
element.bind('submit', handleSubmit);
}
};
}]);
})();