in modules/closure/select/select.js [367:417]
mdSelectCtrl.setSelectValueText = function(text) {
var useDefaultText = text === undefined || text === '';
// Whether the select label has been given via user content rather than the internal
// template of <md-option>
var isSelectLabelFromUser = false;
mdSelectCtrl.setIsPlaceholder(!text);
if (attrs.mdSelectedText && attrs.mdSelectedHtml) {
throw Error('md-select cannot have both `md-selected-text` and `md-selected-html`');
}
if (attrs.mdSelectedText || attrs.mdSelectedHtml) {
text = $parse(attrs.mdSelectedText || attrs.mdSelectedHtml)(scope);
isSelectLabelFromUser = true;
} else if (useDefaultText) {
// Use placeholder attribute, otherwise fallback to the md-input-container label
var tmpPlaceholder = attrs.placeholder ||
(containerCtrl && containerCtrl.label ? containerCtrl.label.text() : '');
text = tmpPlaceholder || '';
isSelectLabelFromUser = true;
}
var target = selectValueElement.children().eq(0);
if (attrs.mdSelectedHtml) {
// Using getTrustedHtml will run the content through $sanitize if it is not already
// explicitly trusted. If the ngSanitize module is not loaded, this will
// *correctly* throw an sce error.
target.html($sce.getTrustedHtml(text));
} else if (isSelectLabelFromUser) {
target.text(text);
} else {
// If we've reached this point, the text is not user-provided.
target.html(text);
}
if (useDefaultText) {
// Avoid screen readers double announcing the label name when no value has been selected
selectValueElement.attr('aria-hidden', 'true');
if (!userDefinedLabelledby) {
element.removeAttr('aria-labelledby');
}
} else {
selectValueElement.removeAttr('aria-hidden');
if (!userDefinedLabelledby) {
element.attr('aria-labelledby', element[0].id + ' ' + selectValueElement[0].id);
}
}
};