angular-filter icon indicating copy to clipboard operation
angular-filter copied to clipboard

using Filter Inside a controller

Open amer4 opened this issue 9 years ago • 2 comments

Hi, How can we use this filters inside a angularjs controller. It works fine when I use it inside html with ng repeat

"data-ng-repeat="orders in orderList | unique: 'submission_Date'"

but when I try to use it inside my controller then it is not working properly

console.log($filter('unique')($scope.orderList ,$scope.orderList .submission_Date));

amer4 avatar Oct 01 '15 15:10 amer4

You will need to run a loop inside the controller too Eg:

angular.forEach($scope.orderList, function(order) {
    // Your filter
})

duongtdvn avatar Oct 01 '15 15:10 duongtdvn

@amer4 think this will work:

$filter('unique')($scope.orderList, 'submission_Date');

toddbranch avatar Dec 03 '15 20:12 toddbranch