File tree 2 files changed +29
-1
lines changed
2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -281,7 +281,7 @@ var SelectController =
281
281
var removeValue = optionAttrs . value ;
282
282
283
283
self . removeOption ( removeValue ) ;
284
- self . ngModelCtrl . $render ( ) ;
284
+ scheduleRender ( ) ;
285
285
286
286
if ( self . multiple && currentValue && currentValue . indexOf ( removeValue ) !== - 1 ||
287
287
currentValue === removeValue
Original file line number Diff line number Diff line change @@ -2316,6 +2316,34 @@ describe('select', function() {
2316
2316
2317
2317
} ) ;
2318
2318
2319
+ it ( 'should keep the ngModel value when the selected option is recreated by ngRepeat' , function ( ) {
2320
+
2321
+ scope . options = [ 'A' , 'B' , 'C' ] ;
2322
+ scope . obj = {
2323
+ value : 'B'
2324
+ } ;
2325
+
2326
+ compile (
2327
+ '<select ng-model="obj.value">' +
2328
+ '<option ng-repeat="option in options" value="{{option}}">{{option}}</option>' +
2329
+ '</select>'
2330
+ ) ;
2331
+
2332
+ var optionElements = element . find ( 'option' ) ;
2333
+ expect ( optionElements . length ) . toEqual ( 3 ) ;
2334
+ expect ( optionElements [ 0 ] . value ) . toBe ( 'A' ) ;
2335
+ expect ( optionElements [ 1 ] ) . toBeMarkedAsSelected ( ) ;
2336
+
2337
+ scope . $apply ( function ( ) {
2338
+ scope . options = [ 'B' , 'C' , 'D' ] ;
2339
+ } ) ;
2340
+
2341
+ optionElements = element . find ( 'option' ) ;
2342
+ expect ( optionElements . length ) . toEqual ( 3 ) ;
2343
+ expect ( optionElements [ 0 ] . value ) . toBe ( 'B' ) ;
2344
+ expect ( optionElements [ 0 ] ) . toBeMarkedAsSelected ( ) ;
2345
+ } ) ;
2346
+
2319
2347
} ) ;
2320
2348
2321
2349
You can’t perform that action at this time.
0 commit comments