-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
If the model is blurred during an apply it should trigger $setTouched asynchronously. Fixes #8762 Fixes #9808 Closes #10014
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2497,7 +2497,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$ | |
</file> | ||
* </example> | ||
*/ | ||
var ngModelDirective = function() { | ||
var ngModelDirective = ['$rootScope', function($rootScope) { | ||
return { | ||
restrict: 'A', | ||
require: ['ngModel', '^?form', '^?ngModelOptions'], | ||
|
@@ -2541,15 +2541,17 @@ var ngModelDirective = function() { | |
element.on('blur', function(ev) { | ||
if (modelCtrl.$touched) return; | ||
|
||
scope.$apply(function() { | ||
modelCtrl.$setTouched(); | ||
}); | ||
if ($rootScope.$$phase) { | ||
scope.$evalAsync(modelCtrl.$setTouched); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
alexanderchan
Author
Contributor
|
||
} else { | ||
scope.$apply(modelCtrl.$setTouched); | ||
} | ||
}); | ||
} | ||
}; | ||
} | ||
}; | ||
}; | ||
}]; | ||
|
||
|
||
/** | ||
|
@Narretz, @alexanderchan: I don't know why I didn't notice this earlier, but is there any particular reason for not calling
$setTouched()
rightaway ?