Scope Variable Is Deleted With Ng-model-options When $validators Return False
Here is the fiddle of my problem. It is very simple... it seems like angular encounters a problem. http://plnkr.co/edit/5diCIhFoWX8FneSSBkfA?p=preview Description: I'm using ng-mo
Solution 1:
It appears that this is correct behavior in Angularjs, which means what would you like to do instead?
Here are a few options...
By adding allowInvalid: true to your options, will present with your text being rendered, but then you are negating the validation.
Check out the updated plunker link
ng-model-options="{ updateOn : 'blur', allowInvalid: true }"
UPDATE
Trying to find $validators in Angular code base, perhaps this has something to do with it as correct behavior.
ctrl.$$runValidators(modelValue, viewValue, function(allValid) {
// If there was no change in validity, don't update the model// This prevents changing an invalid modelValue to undefinedif (!allowInvalid && prevValid !== allValid) {
// Note: Don't check ctrl.$valid here, as we could have// external validators (e.g. calculated on the server),// that just call $setValidity and need the model value// to calculate their validity.
ctrl.$modelValue = allValid ? modelValue : undefined;
Looks like the ctrl.$modalValue is getting set to the update only if the model passes validation, or it gets undefined, which is why your
<pre> {{ appCtrl.test }} </pre>
is disappearing on you. There is no value to present.
Post a Comment for "Scope Variable Is Deleted With Ng-model-options When $validators Return False"