netx netx - 4 months ago 72
AngularJS Question

orderby date angularjs ng-repeat

i'm trying to orderby 'date' together with ng-repeat but my date format is "date": "Sun, 01 Sep 2016 08:47:53 -0400". i tried using momentjs but i'm getting a wrong list.

pls, how do i orderby date

<tr ng-repeat="expense in expenses | orderBy:'date'">
<td>{{ | amTimeAgo}} </td>


You can create your custom filter dateOrder which gives input to in built filter.

JS :


   return function(data){ 
       val.dateTimestamp = new Date(

     return data; 


Define your html as :

<tr ng-repeat="expense in expenses | dateOrder |orderBy :'dateTimestamp'">

Here is the working codepen