From Angular\'s documentation it follows that ngSubmit is a preferred way of submitting a form. All pending operations are immediately finished and $submitted
f
You can modify your directive code a bit like:
function wuSubmit() {
return {
require: 'form',
restrict: 'A',
link: function(scope, element, attributes) {
var scope = element.scope();
if (attributes.name && scope[attributes.name]) {
scope[attributes.name].$submit = function() {
// Parse the handler of submit & execute that.
var fn = $parse(attr.ngSubmit);
$scope.$apply(function() {
fn($scope, {$event: e});
});
};
}
}
};
}
Here you don't have to add wu-submit
everywhere. ng-submit
will work.
Hope this helps!