MCPcopy
hub / github.com/angular-ui/ui-router / ngOptionsPostLink

Function ngOptionsPostLink

test/angular/1.4/angular.js:27000–27341  ·  view source on GitHub ↗
(scope, selectElement, attr, ctrls)

Source from the content-addressed store, hash-verified

26998
26999
27000 function ngOptionsPostLink(scope, selectElement, attr, ctrls) {
27001
27002 // if ngModel is not defined, we don't need to do anything
27003 var ngModelCtrl = ctrls[1];
27004 if (!ngModelCtrl) return;
27005
27006 var selectCtrl = ctrls[0];
27007 var multiple = attr.multiple;
27008
27009 // The emptyOption allows the application developer to provide their own custom "empty"
27010 // option when the viewValue does not match any of the option values.
27011 var emptyOption;
27012 for (var i = 0, children = selectElement.children(), ii = children.length; i < ii; i++) {
27013 if (children[i].value === '') {
27014 emptyOption = children.eq(i);
27015 break;
27016 }
27017 }
27018
27019 var providedEmptyOption = !!emptyOption;
27020
27021 var unknownOption = jqLite(optionTemplate.cloneNode(false));
27022 unknownOption.val('?');
27023
27024 var options;
27025 var ngOptions = parseOptionsExpression(attr.ngOptions, selectElement, scope);
27026
27027
27028 var renderEmptyOption = function() {
27029 if (!providedEmptyOption) {
27030 selectElement.prepend(emptyOption);
27031 }
27032 selectElement.val('');
27033 emptyOption.prop('selected', true); // needed for IE
27034 emptyOption.attr('selected', true);
27035 };
27036
27037 var removeEmptyOption = function() {
27038 if (!providedEmptyOption) {
27039 emptyOption.remove();
27040 }
27041 };
27042
27043
27044 var renderUnknownOption = function() {
27045 selectElement.prepend(unknownOption);
27046 selectElement.val('?');
27047 unknownOption.prop('selected', true); // needed for IE
27048 unknownOption.attr('selected', true);
27049 };
27050
27051 var removeUnknownOption = function() {
27052 unknownOption.remove();
27053 };
27054
27055 // Update the controller methods for multiple selectable options
27056 if (!multiple) {
27057

Callers

nothing calls this directly

Calls 8

isArrayFunction · 0.85
parseOptionsExpressionFunction · 0.70
removeUnknownOptionFunction · 0.70
removeEmptyOptionFunction · 0.70
renderEmptyOptionFunction · 0.70
renderUnknownOptionFunction · 0.70
forEachFunction · 0.70
updateOptionsFunction · 0.70

Tested by

no test coverage detected