-1

I am trying to order a list by date and popularity. From service i have a json response which has date in string format. Is it possible to change the date from Http get response to date object so that i want to use OrderBy filter to sort the list by date.

My json is

{
  "Name": "Paul ",
  "Country": "SINGAPORE",
  "Date": "12/31/14 20:40",
  "Rating": "2"
}
br.julien
  • 3,420
  • 2
  • 23
  • 44
thechoosenone
  • 129
  • 2
  • 8
  • 16

1 Answers1

1

You could pass the date string to the Date Object Put this in your controller:

myApp.controller("MyPersonController", function($scope){
    for (var i in $scope.persons) {
        $scope.persons[i].Date = new Date($scope.persons[i].Date);
    }
});

If you have problems with formatting, I would recommend a date wrapper like MomentJs

com2ghz
  • 2,706
  • 3
  • 16
  • 27