mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
fix(input): treat all not number model as blank
This commit is contained in:
parent
5857c44e0c
commit
aba9bb2a24
2 changed files with 15 additions and 3 deletions
|
|
@ -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
|
||||
: '';
|
||||
};
|
||||
}];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -449,6 +449,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('<input type="number" ng:model="value" >')($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('<input type="text"/>');
|
||||
|
|
|
|||
Loading…
Reference in a new issue