@@ -205,7 +205,7 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) {
205
205
var animate = $animator ( $scope , $attr ) ;
206
206
var expression = $attr . ngRepeat ;
207
207
var match = expression . match ( / ^ \s * ( .+ ) \s + i n \s + ( .* ?) \s * ( \s + t r a c k \s + b y \s + ( .+ ) \s * ) ? $ / ) ,
208
- trackByExp , trackByExpGetter , trackByIdFn , lhs , rhs , valueIdentifier , keyIdentifier ,
208
+ trackByExp , trackByExpGetter , trackByIdFn , trackByIdArrayFn , trackByIdObjFn , lhs , rhs , valueIdentifier , keyIdentifier ,
209
209
hashFnLocals = { $id : hashKey } ;
210
210
211
211
if ( ! match ) {
@@ -227,9 +227,12 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) {
227
227
return trackByExpGetter ( $scope , hashFnLocals ) ;
228
228
} ;
229
229
} else {
230
- trackByIdFn = function ( key , value ) {
230
+ trackByIdArrayFn = function ( key , value ) {
231
231
return hashKey ( value ) ;
232
232
}
233
+ trackByIdObjFn = function ( key ) {
234
+ return key ;
235
+ }
233
236
}
234
237
235
238
match = lhs . match ( / ^ (?: ( [ \$ \w ] + ) | \( ( [ \$ \w ] + ) \s * , \s * ( [ \$ \w ] + ) \) ) $ / ) ;
@@ -266,7 +269,9 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) {
266
269
267
270
if ( isArrayLike ( collection ) ) {
268
271
collectionKeys = collection ;
272
+ trackByIdFn = trackByIdFn || trackByIdArrayFn ;
269
273
} else {
274
+ trackByIdFn = trackByIdFn || trackByIdObjFn ;
270
275
// if object, extract keys, sort them and use to determine order of iteration over obj props
271
276
collectionKeys = [ ] ;
272
277
for ( key in collection ) {
0 commit comments