@@ -243,7 +243,7 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
243
243
widget . $apply ( function ( ) {
244
244
var optionGroup ,
245
245
collection = valuesFn ( modelScope ) || [ ] ,
246
- tempScope = inherit ( modelScope ) ,
246
+ locals = { } ,
247
247
key , value , optionElement , index , groupIndex , length , groupLength ;
248
248
249
249
if ( multiple ) {
@@ -257,9 +257,9 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
257
257
for ( index = 1 , length = optionGroup . length ; index < length ; index ++ ) {
258
258
if ( ( optionElement = optionGroup [ index ] . element ) [ 0 ] . selected ) {
259
259
key = optionElement . val ( ) ;
260
- if ( keyName ) tempScope [ keyName ] = key ;
261
- tempScope [ valueName ] = collection [ key ] ;
262
- value . push ( valueFn ( tempScope ) ) ;
260
+ if ( keyName ) locals [ keyName ] = key ;
261
+ locals [ valueName ] = collection [ key ] ;
262
+ value . push ( valueFn ( modelScope , locals ) ) ;
263
263
}
264
264
}
265
265
}
@@ -270,9 +270,9 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
270
270
} else if ( key == '' ) {
271
271
value = null ;
272
272
} else {
273
- tempScope [ valueName ] = collection [ key ] ;
274
- if ( keyName ) tempScope [ keyName ] = key ;
275
- value = valueFn ( tempScope ) ;
273
+ locals [ valueName ] = collection [ key ] ;
274
+ if ( keyName ) locals [ keyName ] = key ;
275
+ value = valueFn ( modelScope , locals ) ;
276
276
}
277
277
}
278
278
if ( isDefined ( value ) && modelScope . $viewVal !== value ) {
@@ -296,7 +296,7 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
296
296
keys = keyName ? sortedKeys ( values ) : values ,
297
297
groupLength , length ,
298
298
groupIndex , index ,
299
- optionScope = inherit ( modelScope ) ,
299
+ locals = { } ,
300
300
selected ,
301
301
selectedSet = false , // nothing is selected yet
302
302
lastElement ,
@@ -312,21 +312,21 @@ var selectDirective = ['$formFactory', '$compile', '$parse',
312
312
313
313
// We now build up the list of options we need (we merge later)
314
314
for ( index = 0 ; length = keys . length , index < length ; index ++ ) {
315
- optionScope [ valueName ] = values [ keyName ? optionScope [ keyName ] = keys [ index ] :index ] ;
316
- optionGroupName = groupByFn ( optionScope ) || '' ;
315
+ locals [ valueName ] = values [ keyName ? locals [ keyName ] = keys [ index ] :index ] ;
316
+ optionGroupName = groupByFn ( modelScope , locals ) || '' ;
317
317
if ( ! ( optionGroup = optionGroups [ optionGroupName ] ) ) {
318
318
optionGroup = optionGroups [ optionGroupName ] = [ ] ;
319
319
optionGroupNames . push ( optionGroupName ) ;
320
320
}
321
321
if ( multiple ) {
322
- selected = selectedSet . remove ( valueFn ( optionScope ) ) != undefined ;
322
+ selected = selectedSet . remove ( valueFn ( modelScope , locals ) ) != undefined ;
323
323
} else {
324
- selected = modelValue === valueFn ( optionScope ) ;
324
+ selected = modelValue === valueFn ( modelScope , locals ) ;
325
325
selectedSet = selectedSet || selected ; // see if at least one item is selected
326
326
}
327
327
optionGroup . push ( {
328
328
id : keyName ? keys [ index ] : index , // either the index into array or key from object
329
- label : displayFn ( optionScope ) || '' , // what will be seen by the user
329
+ label : displayFn ( modelScope , locals ) || '' , // what will be seen by the user
330
330
selected : selected // determine if we should be selected
331
331
} ) ;
332
332
}
0 commit comments