diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 69d5149fa1a9..2dd1dc32a859 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -1029,7 +1029,7 @@ function baseInputType(scope, element, attr, ctrl, $sniffer, $browser) { element.on('change', listener); ctrl.$render = function() { - element.val(ctrl.$isEmpty(ctrl.$modelValue) ? '' : ctrl.$viewValue); + element.val(ctrl.$viewValue || ''); }; } diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js index 0366aa786aaa..a7d46e4c936a 100644 --- a/test/ng/directive/inputSpec.js +++ b/test/ng/directive/inputSpec.js @@ -484,6 +484,7 @@ describe('NgModelController', function() { }); + describe('validations pipeline', function() { it('should perform validations when $validate() is called', function() { @@ -2075,6 +2076,21 @@ describe('input', function() { expect(inputElm.val()).toBe('0'); }); + it('should render the $viewValue when $modelValue is empty', function() { + compileInput(''); + + var ctrl = inputElm.controller('ngModel'); + + ctrl.$modelValue = null; + + expect(ctrl.$isEmpty(ctrl.$modelValue)).toBe(true); + + ctrl.$viewValue = 'abc'; + ctrl.$render(); + + expect(inputElm.val()).toBe('abc'); + }); + describe('pattern', function() {