@@ -248,15 +248,17 @@ var ngOptionsDirective = ['$compile', '$parse', function($compile, $parse) {
248
248
var getGroupName = function ( value , key ) { return callExpression ( groupByFn , value , key ) || '' ; } ;
249
249
var getValues = function ( ) { return valuesFn ( scope ) || [ ] ; } ;
250
250
var getDisplayLabel = function ( value , key ) { return callExpression ( displayFn , value , key ) ; } ;
251
- var getTrackByValue = function ( value , key ) {
252
- return '' + callExpression ( trackByFn , value , key ) ;
253
- } ;
254
251
var getViewValue = function ( value , key ) {
255
252
return ( key === '?' ) ? undefined :
256
253
( key === '' ) ? null :
257
254
callExpression ( viewValueFn , value , key ) ;
258
255
} ;
259
256
257
+ // Get the value that represents the object in the options collection
258
+ var getTrackByValue = trackByFn ? function ( value , key ) {
259
+ return '' + callExpression ( trackByFn , value , key ) ;
260
+ } : function ( value , key ) { return hashKey ( value ) ; } ;
261
+
260
262
// Get the value that is assigned to and compared to the value of the options
261
263
var getSelectValue = trackByFn ? getTrackByValue : function ( value , key ) {
262
264
return hashKey ( getViewValue ( value , key ) ) ;
@@ -304,11 +306,7 @@ var ngOptionsDirective = ['$compile', '$parse', function($compile, $parse) {
304
306
items : optionItems ,
305
307
selectValueMap : selectValueMap ,
306
308
getOptionFromViewValue : function ( value ) {
307
- if ( ! ! trackBy ) {
308
- return selectValueMap . get ( getTrackByValue ( value ) ) ;
309
- } else {
310
- return selectValueMap . get ( hashKey ( value ) ) ;
311
- }
309
+ return selectValueMap . get ( getTrackByValue ( value ) ) ;
312
310
}
313
311
} ;
314
312
}
0 commit comments