diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index 49f38ebbeca5..40a18d66dba2 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -2142,7 +2142,10 @@ var ngValueDirective = function() {
* makes it possible to use ngValue as a sort of one-way bind.
*/
function updateElementValue(element, attr, value) {
- element.prop('value', value);
+ // Support: IE9 only
+ // In IE9 values are converted to string (e.g. `input.value = null` results in `input.value === 'null'`).
+ var propValue = isDefined(value) ? value : (msie === 9) ? '' : null;
+ element.prop('value', propValue);
attr.$set('value', value);
}
diff --git a/test/ng/directive/inputSpec.js b/test/ng/directive/inputSpec.js
index 47515471122e..c254e62e4042 100644
--- a/test/ng/directive/inputSpec.js
+++ b/test/ng/directive/inputSpec.js
@@ -4211,6 +4211,26 @@ describe('input', function() {
expect(inputElm[0].getAttribute('value')).toBe('something');
});
+ it('should clear the "dom" value property and attribute when the value is undefined', function() {
+ var inputElm = helper.compileInput('');
+
+ $rootScope.$apply('value = "something"');
+
+ expect(inputElm[0].value).toBe('something');
+ expect(inputElm[0].getAttribute('value')).toBe('something');
+
+ $rootScope.$apply(function() {
+ delete $rootScope.value;
+ });
+
+ expect(inputElm[0].value).toBe('');
+ // Support: IE 9-11
+ // In IE it is not possible to remove the `value` attribute from an input element.
+ if (!msie) {
+ expect(inputElm[0].getAttribute('value')).toBeNull();
+ }
+ });
+
they('should update the $prop "value" property and attribute after the bound expression changes', {
input: '',
textarea: ''