Reputation: 3
I need to turn on/off filter in my dir-paginate section
I tried to get $scope
variable from controller to my .filter but I have troubles to achieve it..
<tr dir-paginate="item in items | lastEntry:queryFrom:queryTo">
.filter('lastEntry', function() {
return function(data, greaterThan, lowerThan) {
data=data.filter(function(item){
return item.lastEntry > greaterThan $$ item.lastEntry < lowerThan;
});
return data;
};
});
Upvotes: 0
Views: 71
Reputation: 103348
Generally your code looks fine, however I think you have a syntax error.
If you're looking for an and condition then $$
should be &&
:
return item.lastEntry > greaterThan && item.lastEntry < lowerThan;
I wrote an article a few years back with a working example of conditional filters with AngularJs which you may find useful:
https://curtistimson.co.uk/post/angularjs/filtering-arrays-in-angularjs/
Upvotes: 1