This might be simple but i am not sure how to go about it. I have created two scope array(not sure if required in controller) and my actual list in controller
$scope.tagFilter = [{tag_id:1,tag_name:test},{tag_id:2,tag_name:test2}];
$scope.categoryFilter = [{cat_id:1,cat_name:test3},{cat_id:2,cat_name:test4}]
my actual list
$scope.list = [{list_id:1,category_id:1,tag:1},...]
Is it possible to create a filter where i can compare tag_id with tag in list and cat_id with category_id I was thinking of creating angular.module.filter but not really sure how to do it
You can write a filter
function which behaves in the following way:
var allowed_tags = $scope.tagFilter.map(function(item){
return item.tag_id;
})
var allowed_cat = $scope.categoryFilter.map(function(item){
return item.cat_id;
})
var filtered = $scope.list.filter(function(i){
return ((allowed_tags.indexOf(i.tag) != -1) &&
(allowed_cat.indexOf(i.category_id) != -1));
})
console.log(filtered);