@@ -1200,6 +1200,42 @@ describe('form', function() {
1200
1200
} ) ;
1201
1201
} ) ;
1202
1202
1203
+ fdescribe ( '$getControls' , function ( ) {
1204
+ it ( 'should return a shallow copy of the form controls' , function ( ) {
1205
+ doc = $compile (
1206
+ '<form name="testForm">' +
1207
+ '<input ng-model="named" name="foo">' +
1208
+ '<div ng-form>' +
1209
+ '<input ng-model="named" name="foo">' +
1210
+ '</div>' +
1211
+ '</form>' ) ( scope ) ;
1212
+
1213
+ scope . $digest ( ) ;
1214
+
1215
+ var form = doc ,
1216
+ formCtrl = scope . testForm ,
1217
+ formInput = form . children ( 'input' ) . eq ( 0 ) ,
1218
+ formInputCtrl = formInput . controller ( 'ngModel' ) ,
1219
+ nestedForm = form . find ( 'div' ) ,
1220
+ nestedFormCtrl = nestedForm . controller ( 'form' ) ,
1221
+ nestedInput = nestedForm . children ( 'input' ) . eq ( 0 ) ,
1222
+ nestedInputCtrl = nestedInput . controller ( 'ngModel' ) ;
1223
+
1224
+ var controls = formCtrl . $getControls ( ) ;
1225
+
1226
+ expect ( controls ) . not . toBe ( formCtrl . $$controls ) ;
1227
+
1228
+ controls . push ( 'something' ) ;
1229
+ expect ( formCtrl . $$controls ) . not . toContain ( 'something' ) ;
1230
+
1231
+ expect ( controls [ 0 ] ) . toBe ( formInputCtrl ) ;
1232
+ expect ( controls [ 1 ] ) . toBe ( nestedFormCtrl ) ;
1233
+
1234
+ var nestedControls = controls [ 1 ] . $getControls ( ) ;
1235
+
1236
+ expect ( nestedControls [ 0 ] ) . toBe ( nestedInputCtrl ) ;
1237
+ } ) ;
1238
+ } ) ;
1203
1239
1204
1240
it ( 'should rename nested form controls when interpolated name changes' , function ( ) {
1205
1241
scope . idA = 'A' ;
0 commit comments