jQuery .submit() replacement with angular?

2019-09-04 15:24发布

问题:

Is there angular event trigger function, like we have with jQuery for following action?

$('.link').click(function () {
    $('form').submit(); // this will submit form 
});

Please note, that this is not onSubmit function which is mostly <form ng-submit="submit()"/>

回答1:

You can use ng-click to call a function in your controller to execute form submission.

$('form').submit()

using jQuery

or

document.getElementById('someForm').submit()

using JavaScript