I'm looking for help with sorting a list in Angular 1 when a button is clicked. I want the ability to toggle between ascending and descending order on each click. Here is a link to the code: https://plnkr.co/edit/HYuk7DAgOY6baWhrvXko?p=preview
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":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="abc5caddcecec585c5d8c2df9392ebccc6cac2c785c8c4c6">[email protected]</a>"
},
{
"name":"sss",
"Location":"Delhi",
"email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="365857405353581858455f420e0f76515b575f5a1855595b">[email protected]</a>"
},
{
"name":"aa",
"Location":"Delhi",
"email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dcb2bdaab9b9b2f2b2afb5a8e4e59cbbb1bdb5b0f2bfb3b1">[email protected]</a>"
},
{
"name":"zzz",
"Location":"Delhi",
"email":"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e987889f8c8c87c7879a809dd1d0a98e84888085c78a8684">[email protected]</a>"
}
]
$scope.sortButtonClick =function(){
$scope.sortDir = "DESC"
}
});