File tree 2 files changed +19
-1
lines changed
2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -75,9 +75,11 @@ var SelectController =
75
75
}
76
76
} ;
77
77
78
+ var scopeDestroyed = false ;
78
79
$scope . $on ( '$destroy' , function ( ) {
79
80
// disable unknown option so that we don't do work when the whole select is being destroyed
80
81
self . renderUnknownOption = noop ;
82
+ scopeDestroyed = true ;
81
83
} ) ;
82
84
83
85
// Read the value of the select control, the implementation of this changes depending
@@ -179,6 +181,8 @@ var SelectController =
179
181
updateScheduled = true ;
180
182
181
183
$scope . $$postDigest ( function ( ) {
184
+ if ( scopeDestroyed ) return ;
185
+
182
186
updateScheduled = false ;
183
187
self . ngModelCtrl . $setViewValue ( self . readValue ( ) ) ;
184
188
if ( renderAfter ) self . ngModelCtrl . $render ( ) ;
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ describe('select', function() {
7
7
formElement = jqLite ( '<form name="form">' + html + '</form>' ) ;
8
8
element = formElement . find ( 'select' ) ;
9
9
$compile ( formElement ) ( scope ) ;
10
- scope . $apply ( ) ;
10
+ scope . $digest ( ) ;
11
11
}
12
12
13
13
function compileRepeatedOptions ( ) {
@@ -767,6 +767,20 @@ describe('select', function() {
767
767
expect ( element ) . toEqualSelect ( [ unknownValue ( ) ] , '1' , '2' , '3' ) ;
768
768
}
769
769
) ;
770
+
771
+
772
+ it ( 'should not break when removing the element and all its children' , function ( ) {
773
+ var template =
774
+ '<select ng-model="mySelect" ng-if="visible">' +
775
+ '<option value="">--- Select ---</option>' +
776
+ '</select>' ;
777
+ scope . visible = true ;
778
+
779
+ compile ( template ) ;
780
+
781
+ // It should not throw when removing the element
782
+ scope . $apply ( 'visible = false' ) ;
783
+ } ) ;
770
784
} ) ;
771
785
772
786
You can’t perform that action at this time.
0 commit comments