This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +13
-2
lines changed
2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ function FormController(element, attrs) {
40
40
errors = form . $error = { } ;
41
41
42
42
// init state
43
- form . $name = attrs . name ;
43
+ form . $name = attrs . name || attrs . ngForm ;
44
44
form . $dirty = false ;
45
45
form . $pristine = true ;
46
46
form . $valid = true ;
@@ -102,7 +102,7 @@ function FormController(element, attrs) {
102
102
*
103
103
* @description
104
104
* Sets the validity of a form control.
105
- *
105
+ *
106
106
* This method will also propagate to parent forms.
107
107
*/
108
108
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