Difference between angular submit and ngSubmit events?
submit
: It is html default form submit event, it will call underlying method when form gets submitted.
ngSubmit
: Is host binding situated on form
element. Basically it prevent default submit
event of browser(which can be form post
) by returning false. Eventually you can prevent traditional PostBack
calls or page reload due to form load. This way you can validate your form & submit it to server by manual ajax from Component
code
ngSubmit ensures that the form doesn’t submit when the handler code throws and causes an actual http post request.
from https://blog.thoughtram.io/angular/2016/03/21/template-driven-forms-in-angular-2.html