I have a variable on the scope which I use to check for condition
$scope.data = $resource().query(); //returns array always
So i have a regular validation with a ng-required directive
<input ng-required="{{data.length}}"/>
now when the data is initially loaded into a 2 length array the ng-required validates the field and everything works, but if I were to set ng-required to [], ng-required will still validate as a regular required,
$scope.$apply(function(){
$scope.data = []
});
how do I disable validation on ng-validation = "false" again.
ng-required
accepts an expression, no need to wrap in {{
}}
<input ng-required="data.length"/>
Basic Example: http://jsfiddle.net/TheSharpieOne/Uxe5Q/ (inspect to see the validation being added and removed.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With