diff --git a/src/widget/input.js b/src/widget/input.js
index 016e23537d5c..5d1705e13378 100644
--- a/src/widget/input.js
+++ b/src/widget/input.js
@@ -594,9 +594,9 @@ function numericRegexpInputType(regexp, error) {
};
widget.$parseModel = function() {
- if (isNumber(widget.$modelValue)) {
- widget.$viewValue = '' + widget.$modelValue;
- }
+ widget.$viewValue = isNumber(widget.$modelValue)
+ ? '' + widget.$modelValue
+ : '';
};
}];
}
diff --git a/test/widget/inputSpec.js b/test/widget/inputSpec.js
index 8a35407bbd82..fa182549e518 100644
--- a/test/widget/inputSpec.js
+++ b/test/widget/inputSpec.js
@@ -433,6 +433,18 @@ describe('widget: input', function() {
});
});
+ describe('number', function(){
+ it('should clear number on non-number', inject(function($compile, $rootScope){
+ $rootScope.value = 123;
+ var element = $compile('')($rootScope);
+ $rootScope.$digest();
+ expect(element.val()).toEqual('123');
+ $rootScope.value = undefined;
+ $rootScope.$digest();
+ expect(element.val()).toEqual('');
+ }));
+ });
+
it('should ignore text widget which have no name', function() {
compile('');