From 41010effa2a421b1424a43fe0900c27e0b1c66ce Mon Sep 17 00:00:00 2001 From: Slaven Tomac Date: Sat, 4 Apr 2015 15:50:45 +0200 Subject: [PATCH 1/3] Dynamic option can hold empty value now so you don't have to initially put it inside select (issue #11470) --- src/ng/directive/select.js | 5 ++++- test/ng/directive/selectSpec.js | 36 +++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index 6533fe8906c5..0bdad8e12c0c 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -83,8 +83,11 @@ var SelectController = // Tell the select control that an option, with the given value, has been added - self.addOption = function(value) { + self.addOption = function(value, element) { assertNotHasOwnProperty(value, '"option value"'); + if (value === '') { + self.emptyOption = element + } var count = optionsMap.get(value) || 0; optionsMap.put(value, count + 1); }; diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js index 5be377aa54ee..5d5d2915339a 100644 --- a/test/ng/directive/selectSpec.js +++ b/test/ng/directive/selectSpec.js @@ -200,6 +200,42 @@ describe('select', function() { describe('empty option', function() { + it ('should allow dynamic empty option', function() { + scope.dynamicOptions = []; + + compile('' + '' + From 66f45733ab13f3fcf483328ca606f4eef310c4cf Mon Sep 17 00:00:00 2001 From: Slaven Tomac Date: Wed, 8 Apr 2015 22:34:24 +0200 Subject: [PATCH 2/3] Fixed jshint issue (issue ) --- src/ng/directive/select.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index 0bdad8e12c0c..4833331fb49d 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -86,7 +86,7 @@ var SelectController = self.addOption = function(value, element) { assertNotHasOwnProperty(value, '"option value"'); if (value === '') { - self.emptyOption = element + self.emptyOption = element; } var count = optionsMap.get(value) || 0; optionsMap.put(value, count + 1); From a809d9a455f1db7b20938e1f8583f7d916268eb4 Mon Sep 17 00:00:00 2001 From: Slaven Tomac Date: Wed, 8 Apr 2015 22:57:01 +0200 Subject: [PATCH 3/3] Fixed jscs issues --- test/ng/directive/selectSpec.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js index 5d5d2915339a..2e6c78d8dc40 100644 --- a/test/ng/directive/selectSpec.js +++ b/test/ng/directive/selectSpec.js @@ -200,7 +200,7 @@ describe('select', function() { describe('empty option', function() { - it ('should allow dynamic empty option', function() { + it('should allow dynamic empty option', function() { scope.dynamicOptions = []; compile('