//下拉框
<select ng-change="change()" ng-model="age" ng-init="age=ages[0]">
//添加需要的下拉框数据
$scope.ages = ["按年龄正序排序", "按年龄倒序排列"];
//排序
$scope.change = function() { | |
var a1 = $scope.age; | |
console.log("--" + a1); | |
if (a1 == "按年龄倒序排列") { | |
console.log(a1 + "----") | |
$scope.persons.sort(function(a, b) { | |
return b.age - a.age; | |
}); | |
} else { | |
$scope.persons.sort(function(a, b) { | |
return a.age - b.age; | |
}); | |
} | |
} |