0
请问您可以告诉我如何在角度1按钮点击排序列表?点击按钮时,我想切换(升序和降序)排序列表。 https://plnkr.co/edit/HYuk7DAgOY6baWhrvXko?p=preview如何在按钮点击的角度1中对列表进行排序?
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
vm =this;
$scope.name = 'World';
$scope.sortDir = "ASC"
$scope.customerData= [
{
"name":"naveen",
"Location":"Delhi",
"email":"[email protected]"
},
{
"name":"sss",
"Location":"Delhi",
"email":"[email protected]"
},
{
"name":"aa",
"Location":"Delhi",
"email":"[email protected]"
},
{
"name":"zzz",
"Location":"Delhi",
"email":"[email protected]"
}
]
$scope.sortButtonClick =function(){
$scope.sortDir = "DESC"
}
});
排序依据是什么?名称?电子邮件?位置?给我们一些工作...... –
我看到你已经设置了'vm = this',但这是我们最后看到'vm'。查看[this](https://toddmotto.com/digging-into-angulars-controller-as-syntax/)文章,了解有关controller-as语法w/examples的一些详细信息。 – Will