I'm not sure how to approach this issue.
I'm receiving a JSON from the server {createdOnT: "Sun Aug 04 10:27:39 IDT 2013"}
. Now I would like to convert the value of the JSON to a javscript Date object. So in my controller I have a function that looks like this
$scope.getdate = function(date) {
var unformatedDate = date;
var formated=unformatedDate.replace("IDT","");
var angformat=new Date(formated);
$rootScope.date = angformat;
return $rootScope.date;
}
In my view I call the function like this
<span ng-class="getdate(val.createdOnT)">
<b>Date:  </b>{{date| date:'medium'}}
</span>
And finally try to orderBy like this
<li ng-repeat="(key, val) in JSON | orderBy:'-date'">
Finally I would like to send the converted value to the DOM and use angular's orderBy filter to order the results in a descending order. My guess is that something is wrong with my flow, because I'm trying to use the orderBy filter before the getdate function converted the dates...
Thanks ahead, Gidon
So, I discovered that the JSON that I was receiving from the server was an Object, and not an Array. That is why the orderBy function did not work, and also why the data in the view was being presented in an un-ordered fashion.