Reputation: 205
I am using a scope variable called "sampledata" in controller. I am displaying data in view using filters on the same:-
<div ng-repeat="value in sampledata|orderBy:sortType | filter: {label:filter_one} | filter: {name_filter: filterName}">
</div>
I want to filter the data in the same way in controller as well. How can i do the same?
Upvotes: 1
Views: 39
Reputation: 136134
You could use this by inject $filter dependency in controller function
function DoFilter() {
var orderedBy = $filter('orderBy')($scope.sampledata, $scope.sortType);
returned $filter('filter')(orderedBy,{label: $scope.filter_one, name_filter: $scope.filterName})
}
Upvotes: 2