1

I am trying to add filter on image click .Actually there is an icon in my demo "V" consider only first one near "inject" on header.I apply click event on that .Actually I want to add orderBy filter in first column on click of image. what I did I reverse the array on button click .But may be come condition when my array is not sorted then I need to first sort the given array .That what I am trying to add filter on image click .I try to read documentation of orderBy but there is nothing written how can we 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 is my code http://plnkr.co/edit/FqL7g2w5yLEREopY4B10?p=preview Here my code is working fine when user click image is come ascending and descending order.but when array is not sorted it is not work ?

1 Answer 1

1

I assume $scope.sortdata is your click, if so, you can add a filter via:

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

Remember to inject $filter into your controller

Sign up to request clarification or add additional context in comments.

2 Comments

but how to add filter of sorting ..could you please tell me how to sort .in ascending or descending
here is my plunker please add for sorting plnkr.co/edit/FqL7g2w5yLEREopY4B10?p=preview

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.