You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
What is the mechanism in AngularJS to avoid the submit state in forms? In others words, I want that a form prevents its default behaviour/state when submit button is clicked.
preventDefault and stopPropagation event methods are not useful.
This sounds like a general support question. Please, use one of the appropriate support channels for these types of questions. GitHub issues are reserved for bug reports and feature requests.
There is a different listener on form/[ng-form] elements that calls formController.$setSubmitted(). The ngSubmit listener only gets executed after the listener that calls $setSubmitted(), so you can't stop that from ngSubmit. e.stopPropagation() does indeed prevent the submit event from propagating upwards, but $setSubmitted() also propagates upwards (and you haven't prevented that) - see #11023 for some discussion.
If you want to be able to cancel both listeners, you need to set up your listener in the pre-linking function of a custom directive with a priority higher than ngSubmit/form/[ng-form].
Activity
gkalpak commentedon Oct 27, 2016
This sounds like a general support question. Please, use one of the appropriate support channels for these types of questions.
GitHub issues are reserved for bug reports and feature requests.
Thx!
gkalpak commentedon Oct 27, 2016
There is a different listener on
form/[ng-form]elements that callsformController.$setSubmitted(). ThengSubmitlistener only gets executed after the listener that calls$setSubmitted(), so you can't stop that fromngSubmit.e.stopPropagation()does indeed prevent thesubmitevent from propagating upwards, but$setSubmitted()also propagates upwards (and you haven't prevented that) - see #11023 for some discussion.If you want to be able to cancel both listeners, you need to set up your listener in the pre-linking function of a custom directive with a priority higher than
ngSubmit/form/[ng-form].