unobtrusive-angular-validation
unobtrusive-angular-validation copied to clipboard
ng-disabled breaks validation if input is prepopulated via ng-model
Testing in Angular 1.2.21, if an input is prepopulated via ng-model
, a required validation error will always be thrown if ng-disabled
ever evaluates to true. If ng-disabled
is always false, then validation still works correctly.
The only solution was to combine ng-disabled
with val-if
, having one evaluate opposite of the other.
Example:
val_if = "ctrl.isTrue"
ng_disabled = "!ctrl.isTrue"
It looks as if ng-disabled
is doing something under the hood that isn't playing nicely with the unobtrusive validation unless you purposefully reset the validation using val_if
.