mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-26 14:43:59 +00:00
chore(select): remove inherit, replace with expression locals
This commit is contained in:
parent
761b2ed85a
commit
6216dc0465
1 changed files with 13 additions and 13 deletions
|
|
@ -243,7 +243,7 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
|
||||||
widget.$apply(function() {
|
widget.$apply(function() {
|
||||||
var optionGroup,
|
var optionGroup,
|
||||||
collection = valuesFn(modelScope) || [],
|
collection = valuesFn(modelScope) || [],
|
||||||
tempScope = inherit(modelScope),
|
locals = {},
|
||||||
key, value, optionElement, index, groupIndex, length, groupLength;
|
key, value, optionElement, index, groupIndex, length, groupLength;
|
||||||
|
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
|
|
@ -257,9 +257,9 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
|
||||||
for(index = 1, length = optionGroup.length; index < length; index++) {
|
for(index = 1, length = optionGroup.length; index < length; index++) {
|
||||||
if ((optionElement = optionGroup[index].element)[0].selected) {
|
if ((optionElement = optionGroup[index].element)[0].selected) {
|
||||||
key = optionElement.val();
|
key = optionElement.val();
|
||||||
if (keyName) tempScope[keyName] = key;
|
if (keyName) locals[keyName] = key;
|
||||||
tempScope[valueName] = collection[key];
|
locals[valueName] = collection[key];
|
||||||
value.push(valueFn(tempScope));
|
value.push(valueFn(modelScope, locals));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -270,9 +270,9 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
|
||||||
} else if (key == ''){
|
} else if (key == ''){
|
||||||
value = null;
|
value = null;
|
||||||
} else {
|
} else {
|
||||||
tempScope[valueName] = collection[key];
|
locals[valueName] = collection[key];
|
||||||
if (keyName) tempScope[keyName] = key;
|
if (keyName) locals[keyName] = key;
|
||||||
value = valueFn(tempScope);
|
value = valueFn(modelScope, locals);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isDefined(value) && modelScope.$viewVal !== value) {
|
if (isDefined(value) && modelScope.$viewVal !== value) {
|
||||||
|
|
@ -296,7 +296,7 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
|
||||||
keys = keyName ? sortedKeys(values) : values,
|
keys = keyName ? sortedKeys(values) : values,
|
||||||
groupLength, length,
|
groupLength, length,
|
||||||
groupIndex, index,
|
groupIndex, index,
|
||||||
optionScope = inherit(modelScope),
|
locals = {},
|
||||||
selected,
|
selected,
|
||||||
selectedSet = false, // nothing is selected yet
|
selectedSet = false, // nothing is selected yet
|
||||||
lastElement,
|
lastElement,
|
||||||
|
|
@ -312,21 +312,21 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
|
||||||
|
|
||||||
// We now build up the list of options we need (we merge later)
|
// We now build up the list of options we need (we merge later)
|
||||||
for (index = 0; length = keys.length, index < length; index++) {
|
for (index = 0; length = keys.length, index < length; index++) {
|
||||||
optionScope[valueName] = values[keyName ? optionScope[keyName]=keys[index]:index];
|
locals[valueName] = values[keyName ? locals[keyName]=keys[index]:index];
|
||||||
optionGroupName = groupByFn(optionScope) || '';
|
optionGroupName = groupByFn(modelScope, locals) || '';
|
||||||
if (!(optionGroup = optionGroups[optionGroupName])) {
|
if (!(optionGroup = optionGroups[optionGroupName])) {
|
||||||
optionGroup = optionGroups[optionGroupName] = [];
|
optionGroup = optionGroups[optionGroupName] = [];
|
||||||
optionGroupNames.push(optionGroupName);
|
optionGroupNames.push(optionGroupName);
|
||||||
}
|
}
|
||||||
if (multiple) {
|
if (multiple) {
|
||||||
selected = selectedSet.remove(valueFn(optionScope)) != undefined;
|
selected = selectedSet.remove(valueFn(modelScope, locals)) != undefined;
|
||||||
} else {
|
} else {
|
||||||
selected = modelValue === valueFn(optionScope);
|
selected = modelValue === valueFn(modelScope, locals);
|
||||||
selectedSet = selectedSet || selected; // see if at least one item is selected
|
selectedSet = selectedSet || selected; // see if at least one item is selected
|
||||||
}
|
}
|
||||||
optionGroup.push({
|
optionGroup.push({
|
||||||
id: keyName ? keys[index] : index, // either the index into array or key from object
|
id: keyName ? keys[index] : index, // either the index into array or key from object
|
||||||
label: displayFn(optionScope) || '', // what will be seen by the user
|
label: displayFn(modelScope, locals) || '', // what will be seen by the user
|
||||||
selected: selected // determine if we should be selected
|
selected: selected // determine if we should be selected
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue