I want the orderBy: '- name filter to be applied by the button (or checkbox), canceled if pressed again (like true-false). Did not find how this can be implemented.

    1 answer 1

    function Ctrl($scope) { $scope.useFilter = false; $scope.items = [ {name: 'Aaa'}, {name: 'Zzz'}, {name: 'Qqq'}, ]; } 
     <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app ng-controller="Ctrl"> <label><input type="checkbox" ng-model="useFilter"> Use filter</label> <ul> <li ng-repeat="item in useFilter ? (items | orderBy : '-name') : items">{{item.name}}</li> </ul> </div> 

    • Interesting implementation, thanks! - Timur Musharapov