I have a code something like this with ng-repeat = \"(key,value) in data\". In Controller:
$scope.Dates = {\"Today\":\"30\",
\"This Wee
EDIT: I've filed a bug, feel free to +1
ECMAScript does not specify order in which keys should be iterated, however all major browsers implement objects as linked hash map (preserves order) and a lot of js libraries depend on this behavior and so we've got used to it and it's hardly going to change.
Angular on the other hand (which is totally unexpected) sort it alphabetically. I've inspected the source code myself, it is hard-coded there and it would be nice if it got resolved one day. Otherwise the (k, v) in obj
feature is completely useless.
You really cant do anything with that, tricking angular to think your result is an array is not useful for anything, because you would need numeric keys then...
If this is okay, you can define getter for length:
Object.defineProperty(yourResultObjectOrPrototype, 'length', {
get: function(){
return Object.keys(this).length;
}
})
Otherwise you'll need some kind of filter which will iterate object using for(var k in obj)
and store result in array.