This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +14
-3
lines changed
2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ var nullFormCtrl = {
23
23
*
24
24
* - keys are validation tokens (error names) — such as `required`, `url` or `email`),
25
25
* - values are arrays of controls or forms that are invalid with given error.
26
- *
26
+ *
27
27
* @description
28
28
* `FormController` keeps track of all its controls and nested forms as well as state of them,
29
29
* such as being valid/invalid or dirty/pristine.
@@ -42,7 +42,7 @@ function FormController(element, attrs) {
42
42
controls = [ ] ;
43
43
44
44
// init state
45
- form . $name = attrs . name ;
45
+ form . $name = attrs . name || attrs . ngForm ;
46
46
form . $dirty = false ;
47
47
form . $pristine = true ;
48
48
form . $valid = true ;
@@ -108,7 +108,7 @@ function FormController(element, attrs) {
108
108
*
109
109
* @description
110
110
* Sets the validity of a form control.
111
- *
111
+ *
112
112
* This method will also propagate to parent forms.
113
113
*/
114
114
form . $setValidity = function ( validationToken , isValid , control ) {
Original file line number Diff line number Diff line change @@ -63,6 +63,17 @@ describe('form', function() {
63
63
expect ( scope . myForm . alias ) . toBeDefined ( ) ;
64
64
} ) ;
65
65
66
+ it ( 'should use ngForm value as form name when nested inside form' , function ( ) {
67
+ doc = $compile (
68
+ '<form name="myForm">' +
69
+ '<div ng-form="nestedForm"><input type="text" name="alias" ng-model="value"/></div>' +
70
+ '</form>' ) ( scope ) ;
71
+
72
+ expect ( scope . myForm ) . toBeDefined ( ) ;
73
+ expect ( scope . myForm . nestedForm ) . toBeDefined ( ) ;
74
+ expect ( scope . myForm . nestedForm . alias ) . toBeDefined ( ) ;
75
+ } ) ;
76
+
66
77
67
78
it ( 'should publish form to scope when name attr is defined' , function ( ) {
68
79
doc = $compile ( '<form name="myForm"></form>' ) ( scope ) ;
You can’t perform that action at this time.
0 commit comments