MCPcopy Index your code
hub / github.com/angular-ui/ui-router / render

Function render

test/angular/1.2/angular.js:21947–22119  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21945
21946
21947 function render() {
21948 // Temporary location for the option groups before we render them
21949 var optionGroups = {'':[]},
21950 optionGroupNames = [''],
21951 optionGroupName,
21952 optionGroup,
21953 option,
21954 existingParent, existingOptions, existingOption,
21955 modelValue = ctrl.$modelValue,
21956 values = valuesFn(scope) || [],
21957 keys = keyName ? sortedKeys(values) : values,
21958 key,
21959 groupLength, length,
21960 groupIndex, index,
21961 locals = {},
21962 selected,
21963 selectedSet = getSelectedSet(),
21964 lastElement,
21965 element,
21966 label;
21967
21968
21969 // We now build up the list of options we need (we merge later)
21970 for (index = 0; length = keys.length, index < length; index++) {
21971
21972 key = index;
21973 if (keyName) {
21974 key = keys[index];
21975 if ( key.charAt(0) === '$' ) continue;
21976 locals[keyName] = key;
21977 }
21978
21979 locals[valueName] = values[key];
21980
21981 optionGroupName = groupByFn(scope, locals) || '';
21982 if (!(optionGroup = optionGroups[optionGroupName])) {
21983 optionGroup = optionGroups[optionGroupName] = [];
21984 optionGroupNames.push(optionGroupName);
21985 }
21986 if (multiple) {
21987 selected = isDefined(
21988 selectedSet.remove(trackFn ? trackFn(scope, locals) : valueFn(scope, locals))
21989 );
21990 } else {
21991 if (trackFn) {
21992 var modelCast = {};
21993 modelCast[valueName] = modelValue;
21994 selected = trackFn(scope, modelCast) === trackFn(scope, locals);
21995 } else {
21996 selected = modelValue === valueFn(scope, locals);
21997 }
21998 selectedSet = selectedSet || selected; // see if at least one item is selected
21999 }
22000 label = displayFn(scope, locals); // what will be seen by the user
22001
22002 // doing displayFn(scope, locals) || '' overwrites zero values
22003 label = isDefined(label) ? label : '';
22004 optionGroup.push({

Callers 1

setupAsOptionsFunction · 0.70

Calls 4

getSelectedSetFunction · 0.85
sortedKeysFunction · 0.70
isDefinedFunction · 0.70
valueFnFunction · 0.70

Tested by

no test coverage detected