2

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.

1
  • It works on mine, plunker Commented Dec 12, 2014 at 11:33

1 Answer 1

2

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>
Sign up to request clarification or add additional context in comments.

1 Comment

Forgot to mark it correct - It was in fact angular bug. It's ok after upgrade to newer version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.