diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index 07b5f9972de4..6e4961f85668 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -544,8 +544,8 @@ function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
});
if (attr.min) {
- var min = parseFloat(attr.min);
var minValidator = function(value) {
+ var min = parseFloat(attr.min);
if (!ctrl.$isEmpty(value) && value < min) {
ctrl.$setValidity('min', false);
return undefined;
@@ -560,8 +560,8 @@ function numberInputType(scope, element, attr, ctrl, $sniffer, $browser) {
}
if (attr.max) {
- var max = parseFloat(attr.max);
var maxValidator = function(value) {
+ var max = parseFloat(attr.max);
if (!ctrl.$isEmpty(value) && value > max) {
ctrl.$setValidity('max', false);
return undefined;
diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js
index c94eb9b898e1..c60960f06312 100644
--- a/test/ng/directive/inputSpec.js
+++ b/test/ng/directive/inputSpec.js
@@ -667,6 +667,21 @@ describe('input', function() {
expect(scope.value).toBe(100);
expect(scope.form.alias.$error.min).toBeFalsy();
});
+
+ it('should validate even if min value changes on-the-fly', function(done) {
+ scope.min = 10;
+ compileInput('');
+ scope.$digest();
+
+ changeInputValueTo('5');
+ expect(inputElm).toBeInvalid();
+
+ scope.min = 0;
+ scope.$digest(function () {
+ expect(inputElm).toBeValid();
+ done();
+ });
+ });
});
@@ -686,6 +701,21 @@ describe('input', function() {
expect(scope.value).toBe(0);
expect(scope.form.alias.$error.max).toBeFalsy();
});
+
+ it('should validate even if max value changes on-the-fly', function(done) {
+ scope.max = 10;
+ compileInput('');
+ scope.$digest();
+
+ changeInputValueTo('5');
+ expect(inputElm).toBeValid();
+
+ scope.max = 0;
+ scope.$digest(function () {
+ expect(inputElm).toBeInvalid();
+ done();
+ });
+ });
});