Reputation: 403
I've got two input fields of type number. I want second to have minimum attribute dependant on first field. I can dynamically change the attribute, but ng-valid does not change, when value is lower than minimum.
jsfiddle code example: http://jsfiddle.net/NBhn4/87/
Is that a bug or am I doing something wrong? I found this: https://github.com/angular/angular.js/issues/2404. It seems to suggest, that the problem was fixed. In my jsfiddle example I am using angular 1.3.5 and it's still not working.
<input type="number" ng-model="max" min={{min}} name='max'>
Using this, changes the minimum, but ng-valid seems not be be triggered after change.
Upvotes: 2
Views: 2909
Reputation: 46
Its your angularjs version problem I hope. Use latest versions of angularjs and this code is working.
<form name="form" novalidate ng-init="min=1;number=0">
Number:
<input type="number" ng-model="number" name="number" min="{{min}}">
<div style="color: red" ng-show="form.number.$error.min">Number must be at least {{min}}</div><br>
Minimum:
<input type="number" ng-model="min" name="min">
</form>
Upvotes: 2