Here is the controller:
function Ctrl($scope) {
$scope.text = 'guest';
$scope.word = /^\w*$/;
$scope.min_length = 4;
}
Here is the view:
<form name="myForm" ng-controller="Ctrl">
Single word:
<input type="text" name="input" ng-model="text"
ng-pattern="word" ng-minlength="min_length" required />
...
</form>
The ng-minlength="min_length" won't trigger the minlength error except I explicitly write
ng-minlength="4". However, ng-pattern="word" works fine.
Here is the jsfiddle link
Is it because I am doing wrong or there is way to get around?
Here is how you do it with ng-minlength
<input ng-minlength="{{ min_length }}" />
Here it is working
jsFiddle link
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