Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

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 ?

share|improve this question

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

share|improve this answer
    
but how to add filter of sorting ..could you please tell me how to sort .in ascending or descending – Shruti Jun 3 '15 at 14:38
    
here is my plunker please add for sorting plnkr.co/edit/FqL7g2w5yLEREopY4B10?p=preview – Pallavi Sharma Jun 3 '15 at 15:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.