angularjs - how to add filter on button click in angular js? -


i trying add filter on image click .actually there icon in demo "v" consider first 1 near "inject" on header.i apply click event on .actually want add orderby filter in first column on click of image. did reverse array on button click .but may come condition when array not sorted need first sort given array .that trying add filter on image click .i try read documentation of orderby there nothing written how can use button click event . https://docs.angularjs.org/api/ng/filter/orderby

javascript code

$scope.sortdata = function() {       //alert('--')       $scope.displaydata=$scope.displaydata.slice().reverse();   }; 

here code http://plnkr.co/edit/fql7g2w5ylereopy4b10?p=preview here code working fine when user click image come ascending , descending order.but when array not sorted not work ?

i assume $scope.sortdata click, if so, can add filter via:

scope.sortdata = function() {   //alert('--')   $filter('filtername')(argument1, argument2, etc); }; 

remember inject $filter controller


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -