This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 19
19
* element nesting.
20
20
*
21
21
*
22
+ * # Submitting a form and preventing default action
23
+ *
24
+ * Since the role of forms in client-side Angular applications is different than in old-school
25
+ * roundtrip apps, it is desirable for the browser not to translate the form submission into a full
26
+ * page reload that sends the data to the server. Instead some javascript logic should be triggered
27
+ * to handle the form submission in application specific way.
28
+ *
29
+ * For this reason, Angular prevents the default action (form submission to the server) unless the
30
+ * `<form>` element has an `action` attribute specified.
31
+ *
32
+ * You can use one of the following two ways to specify what javascript method should be called when
33
+ * a form is submitted:
34
+ *
35
+ * - ng:submit on the form element (add link to ng:submit)
36
+ * - ng:click on the first button or input field of type submit (input[type=submit])
37
+ *
38
+ * To prevent double execution of the handler, use only one of ng:submit or ng:click. This is
39
+ * because of the following form submission rules coming from the html spec:
40
+ *
41
+ * - If a form has only one input field then hitting enter in this field triggers form submit
42
+ * (`ng:submit`)
43
+ * - if a form has has 2+ input fields and no buttons or input[type=submit] then hitting enter
44
+ * doesn't trigger submit
45
+ * - if a form has one or more input fields and one or more buttons or input[type=submit] then
46
+ * hitting enter in any of the input fields will trigger the click handler on the *first* button or
47
+ * input[type=submit] (`ng:click`) *and* a submit handler on the enclosing form (`ng:submit`)
48
+ *
49
+ * @param {string= } name Name of the form.
50
+ *
22
51
* @example
23
52
<doc:example>
24
53
<doc:source>
You can’t perform that action at this time.
0 commit comments