diff --git a/src/ng/directive/ngOptions.js b/src/ng/directive/ngOptions.js index 405c8879da3f..282dff3aedd2 100644 --- a/src/ng/directive/ngOptions.js +++ b/src/ng/directive/ngOptions.js @@ -626,7 +626,10 @@ var ngOptionsDirective = ['$compile', '$parse', function($compile, $parse) { if (emptyOption_ || unknownOption_) { while (current && (current === emptyOption_ || - current === unknownOption_)) { + current === unknownOption_ || + emptyOption_ && emptyOption_.nodeType === NODE_TYPE_COMMENT)) { + // Empty options might have directives that transclude + // and insert comments (e.g. ngIf) current = current.nextSibling; } } diff --git a/test/ng/directive/ngOptionsSpec.js b/test/ng/directive/ngOptionsSpec.js index a5172bf3fc3a..e9b512f7cbf4 100644 --- a/test/ng/directive/ngOptionsSpec.js +++ b/test/ng/directive/ngOptionsSpec.js @@ -2093,6 +2093,30 @@ describe('ngOptions', function() { expect(element[0].selectedIndex).toEqual(0); expect(scope.selected).toEqual([]); }); + + + it('should be possible to use ngIf in the blank option', function() { + var option; + createSingleSelect(''); + + scope.$apply(function() { + scope.values = [{name: 'A'}]; + scope.isBlank = true; + }); + + expect(element.find('option').length).toBe(2); + option = element.find('option').eq(0); + expect(option.val()).toBe(''); + expect(option.text()).toBe('blank'); + + scope.$apply(function() { + scope.isBlank = false; + }); + + expect(element.find('option').length).toBe(1); + option = element.find('option').eq(0); + expect(option.text()).toBe('A'); + }); });