@@ -958,13 +958,7 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) {
958
958
// value, so it may be necessary to revalidate (by calling $setViewValue again) even if the
959
959
// control's value is the same empty value twice in a row.
960
960
if ( ctrl . $viewValue !== value || ( value === '' && ctrl . $$hasNativeValidators ) ) {
961
- if ( scope . $root . $$phase ) {
962
- ctrl . $setViewValue ( value , event ) ;
963
- } else {
964
- scope . $apply ( function ( ) {
965
- ctrl . $setViewValue ( value , event ) ;
966
- } ) ;
967
- }
961
+ ctrl . $setViewValue ( value , event ) ;
968
962
}
969
963
} ;
970
964
@@ -1218,9 +1212,7 @@ function radioInputType(scope, element, attr, ctrl) {
1218
1212
1219
1213
var listener = function ( ev ) {
1220
1214
if ( element [ 0 ] . checked ) {
1221
- scope . $apply ( function ( ) {
1222
- ctrl . $setViewValue ( attr . value , ev && ev . type ) ;
1223
- } ) ;
1215
+ ctrl . $setViewValue ( attr . value , ev && ev . type ) ;
1224
1216
}
1225
1217
} ;
1226
1218
@@ -1252,9 +1244,7 @@ function checkboxInputType(scope, element, attr, ctrl, $sniffer, $browser, $filt
1252
1244
var falseValue = parseConstantExpr ( $parse , scope , 'ngFalseValue' , attr . ngFalseValue , false ) ;
1253
1245
1254
1246
var listener = function ( ev ) {
1255
- scope . $apply ( function ( ) {
1256
- ctrl . $setViewValue ( element [ 0 ] . checked , ev && ev . type ) ;
1257
- } ) ;
1247
+ ctrl . $setViewValue ( element [ 0 ] . checked , ev && ev . type ) ;
1258
1248
} ;
1259
1249
1260
1250
element . on ( 'click' , listener ) ;
@@ -1633,8 +1623,8 @@ var VALID_CLASS = 'ng-valid',
1633
1623
*
1634
1624
*
1635
1625
*/
1636
- var NgModelController = [ '$scope' , '$exceptionHandler' , '$attrs' , '$element' , '$parse' , '$animate' , '$timeout' ,
1637
- function ( $scope , $exceptionHandler , $attr , $element , $parse , $animate , $timeout ) {
1626
+ var NgModelController = [ '$scope' , '$exceptionHandler' , '$attrs' , '$element' , '$parse' , '$animate' , '$timeout' , '$rootScope' ,
1627
+ function ( $scope , $exceptionHandler , $attr , $element , $parse , $animate , $timeout , $rootScope ) {
1638
1628
this . $viewValue = Number . NaN ;
1639
1629
this . $modelValue = Number . NaN ;
1640
1630
this . $validators = { } ;
@@ -2157,8 +2147,12 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
2157
2147
pendingDebounce = $timeout ( function ( ) {
2158
2148
ctrl . $commitViewValue ( ) ;
2159
2149
} , debounceDelay ) ;
2160
- } else {
2150
+ } else if ( $rootScope . $$phase ) {
2161
2151
ctrl . $commitViewValue ( ) ;
2152
+ } else {
2153
+ $scope . $apply ( function ( ) {
2154
+ ctrl . $commitViewValue ( ) ;
2155
+ } ) ;
2162
2156
}
2163
2157
} ;
2164
2158
@@ -2375,9 +2369,7 @@ var ngModelDirective = function() {
2375
2369
var modelCtrl = ctrls [ 0 ] ;
2376
2370
if ( modelCtrl . $options && modelCtrl . $options . updateOn ) {
2377
2371
element . on ( modelCtrl . $options . updateOn , function ( ev ) {
2378
- scope . $apply ( function ( ) {
2379
- modelCtrl . $$debounceViewValueCommit ( ev && ev . type ) ;
2380
- } ) ;
2372
+ modelCtrl . $$debounceViewValueCommit ( ev && ev . type ) ;
2381
2373
} ) ;
2382
2374
}
2383
2375
0 commit comments