用按钮控制排序(或者说控制器中如何使用过滤器)
思想:按钮控制肯定是ng-click触发
(js访问的变量都是往上找的)项控制器中注入$filter过滤器
<script >
var app=angular.module('test',[])
app.controller('con1',function($scope,$http,$filter){
$scope.date=[
{id:1,name:'xssssssss'},
{id:52,name:'apple'},
{id:44,name:'pear'},
{id:12,name:"orange"}
]
$scope.orderby=function(){
$scope.date=$filter('orderBy')($scope.date,'id',true)
}
})
</script>
$scope.orderby=function(field){
$scope.date=$filter('orderBy')($scope.date,field,参数3)
}
只要能动态切换低三个参数就ok,默认false