<ul ng-repeat="x in data | orderBy:'-time'">
<li>姓名:{{x.name}},時間:{{x.time}}</li>
</ul>
<script>
var app = angular.module("myApp", []);
app.controller('Controller', function ($scope) {
$scope.data=[{name:'ad',id:'01',time:'2017-4-06'},
{name:'zx',id:'02',time:'2017-4-05'},
{name:'lu',id:'02',time:'2017-5-17'}
]
})
</script>
按時間降序排。在字段名前加個“-”號即可。(個人覺得這個方法比較好)
方法二:
<ul ng-repeat="x in data | orderBy:x.time:'desc'">
<li>姓名:{{x.name}},時間:{{x.time}}</li>
</ul>
這個在百度上查到的,但有點問題,感覺不是很好,但有時候也是一種方法