Sorting Angularjs Ng-repeat By Date
I am relatively new to AngularJS. Could use some help I have a table with the following info
Solution 1:Ideally you'd have a sortable object for date. One candidate is an isoformatted date:
Now sorting should work just fine but it'll display wonky. So you'll need to use a date filter to format it on the UI:
Solution 2:As you have noticed, the value you receive is type of string and therefore it is sorted alphabetically. You need to convert it into Date() beforehand. So basically what you need is to loop over the array of data you got and add a new property (or replace existing one) with a new Date object:
I just checked, JavaScript seems to be parsing format "September 13, 2016" pretty well. You may like these posts
|
---|
Post a Comment for "Sorting Angularjs Ng-repeat By Date"