Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

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.

share|improve this question
    
It works on mine, plunker – ryeballar Dec 12 '14 at 11:33
up vote 2 down vote accepted

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>
share|improve this answer
1  
Forgot to mark it correct - It was in fact angular bug. It's ok after upgrade to newer version. – user3146472 Dec 30 '14 at 14:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.