diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js
index 0c94ddcb5c4f..92c7b2210820 100644
--- a/src/ng/directive/select.js
+++ b/src/ng/directive/select.js
@@ -386,7 +386,8 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
selected,
selectedSet = false, // nothing is selected yet
lastElement,
- element;
+ element,
+ label;
if (multiple) {
selectedSet = new HashMap(modelValue);
@@ -410,9 +411,11 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
selected = modelValue === valueFn(scope, locals);
selectedSet = selectedSet || selected; // see if at least one item is selected
}
+ label = displayFn(scope, locals); // what will be seen by the user
+ label = label === undefined ? '' : label; // doing displayFn(scope, locals) || '' overwrites zero values
optionGroup.push({
id: keyName ? keys[index] : index, // either the index into array or key from object
- label: displayFn(scope, locals) || '', // what will be seen by the user
+ label: label,
selected: selected // determine if we should be selected
});
}
diff --git a/test/ng/directive/selectSpec.js b/test/ng/directive/selectSpec.js
index c63d17bfaa66..7d17a1856fd8 100644
--- a/test/ng/directive/selectSpec.js
+++ b/test/ng/directive/selectSpec.js
@@ -493,6 +493,21 @@ describe('select', function() {
expect(sortedHtml(options[2])).toEqual('');
});
+ it('should render zero as a valid display value', function() {
+ createSingleSelect();
+
+ scope.$apply(function() {
+ scope.values = [{name: 0}, {name: 1}, {name: 2}];
+ scope.selected = scope.values[0];
+ });
+
+ var options = element.find('option');
+ expect(options.length).toEqual(3);
+ expect(sortedHtml(options[0])).toEqual('');
+ expect(sortedHtml(options[1])).toEqual('');
+ expect(sortedHtml(options[2])).toEqual('');
+ });
+
it('should render an object', function() {
createSelect({