From aa7f84ecb37341c1b2852a3155a15c5f99cabe40 Mon Sep 17 00:00:00 2001 From: Chris Nicola Date: Wed, 27 Feb 2013 22:03:07 -0800 Subject: [PATCH 1/2] Treat range inputs the same as number inputs --- src/ng/directive/input.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index aaabd1033398..581efc3ed2e3 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -152,7 +152,7 @@ var inputType = { */ 'number': numberInputType, - + 'range': numberInputType, /** * @ngdoc inputType From fb16b9a1aae289b09973704e9c2bfb673eaaaeb8 Mon Sep 17 00:00:00 2001 From: Chris Nicola Date: Wed, 27 Feb 2013 22:18:55 -0800 Subject: [PATCH 2/2] Add a duplicate scenario for the 'range' input to the 'number' input --- src/ng/directive/input.js | 41 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 581efc3ed2e3..4c54221b6b15 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -143,6 +143,47 @@ var inputType = { expect(binding('myForm.input.$valid')).toEqual('false'); }); + it('should be invalid if over max', function() { + input('value').enter('123'); + expect(binding('value')).toEqual(''); + expect(binding('myForm.input.$valid')).toEqual('false'); + }); + + + * @example + + + +
+ Number: + + Required! + + Not valid number! + value = {{value}}
+ myForm.input.$valid = {{myForm.input.$valid}}
+ myForm.input.$error = {{myForm.input.$error}}
+ myForm.$valid = {{myForm.$valid}}
+ myForm.$error.required = {{!!myForm.$error.required}}
+
+
+ + it('should initialize to model', function() { + expect(binding('value')).toEqual('12'); + expect(binding('myForm.input.$valid')).toEqual('true'); + }); + + it('should be invalid if empty', function() { + input('value').enter(''); + expect(binding('value')).toEqual(''); + expect(binding('myForm.input.$valid')).toEqual('false'); + }); + it('should be invalid if over max', function() { input('value').enter('123'); expect(binding('value')).toEqual('');