0

我想按降序排列我的数据,即27,26,25 ....如何做到这一点?如何通过在Angularjs中降序datetime ng-repeat来排序?

<tbody class="gradeX" ng-repeat="x in Profile | orderBy: x.created_datetime"> 
    <tr> 
    <td>{{x.job_title }}</td> 
    <td>{{x.created_datetime | date:'medium' }}</td> 
    <td>{{x.updated_datetime | date:'medium' }}</td> 
    <td>{{x.status}}</td> 
    <td>{{ x.total }}</td> 
    <td class="actions"> <a href="" data-toggle="tooltip" title="Show Invoice Details" ng-click="activeinvoicesCtrl.setCurrentJob(x)"><i class="fa fa-server fa-2x" aria-hidden="true"></i></a> </td> 
    </tr> 
</tbody> 
+0

英语,代码 – Mikkel

回答

0

添加一个字符串与您正在寻找的属性的名称。 如果它是嵌套属性,请使用。到Concat的字符串,如“item.created_datetime”

<tbody class="gradeX" ng-repeat="x in Profile | orderBy: '-created_datetime'"> 
+0

格式,我想在上面 –

+0

最新的日期时间加 - 开头。检查更新的答案 –

0
<tbody class="gradeX" ng-repeat="x in Profile | orderBy: 'created_datetime'"> 
             <tr > 
              <td>{{x.job_title }}</td> 
              <td>{{x.created_datetime | date:'medium' }}</td> 
              <td>{{x.updated_datetime | date:'medium' }}</td> 
              <td>{{x.status}}</td> 
             <td >{{ x.total }}</td> 
             <td class="actions"> 
          <a href="" data-toggle="tooltip" title="Show Invoice Details" ng-click="activeinvoicesCtrl.setCurrentJob(x)"><i class="fa fa-server fa-2x" aria-hidden="true"></i></a> 

         </td>          
             </tr> 
            </tbody> 

确保您created_datetime对象是一个JavaScript日期()对象,如果不是你可能会惊讶地看到,2月1日是前1月2日