ng-repeat by default sort the list on keys.

Here is the code snippet from *AngularJS source 
<https://github.com/angular/angular.js/blob/master/src/ng/directive/ngRepeat.js>*
:

if (isArrayLike(collection)) {
    collectionKeys = collection;
    trackByIdFn = trackByIdExpFn || trackByIdArrayFn;
} else {
    trackByIdFn = trackByIdExpFn || trackByIdObjFn;
    // if object, extract keys, sort them and use to determine order of 
iteration over obj props
    collectionKeys = [];
    for (var itemKey in collection) {
        if (collection.hasOwnProperty(itemKey) && itemKey.charAt(0) != '$') {
            collectionKeys.push(itemKey);
        }
    }
    collectionKeys.sort();
}


If you don't want this default behavior, you must convert the list of keys 
in an array and iterate over it. For value, use the key to fetch the 
related value from the collection.

e.g.
In HTML:

<div ng-repeat="key in keys(Dates)">
    {{key}} ==> {{Dates[key]}}
</div>


In Controller:

$scope.keys = function(obj){
    var retVal = obj? Object.keys(obj) : [];
    return retVal;
};


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to