diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index 838846405818..66e48bc0ef9d 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -73,6 +73,7 @@ var SelectController = if (value === '') self.emptyOption.prop('selected', true); // to make IE9 happy } else { if (isUndefined(value) && self.emptyOption) { + self.removeUnknownOption(); $element.val(''); } else { self.renderUnknownOption(value); diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js index 725c87ddec97..af6262a56166 100644 --- a/test/ng/directive/selectSpec.js +++ b/test/ng/directive/selectSpec.js @@ -237,6 +237,23 @@ describe('select', function() { }); + it('should remove unknown option when model is undefined', function() { + scope.robot = 'other'; + compile(''); + + expect(element).toEqualSelect([unknownValue('other')], '', 'x', 'y'); + + scope.robot = undefined; + scope.$digest(); + + expect(element).toEqualSelect([''], 'x', 'y'); + }); + + describe('interactions with repeated options', function() { it('should select empty option when model is undefined', function() {