Reputation: 191
I have a filter applied on a drop down, but I would like it removed depending on another drop down value. Code below. If the user chooses "Medium" (or any other value), then I need the filter removed that gets applied when the user selects "Small". Right now, if the user chooses "Small" and then "Medium", the options are still being filtered out.
if(val == "Small"){
$scope.Variant.Specs.Color.Options = $scope.Variant.Specs.Color.Options.filter(function(item) {
return item.Value !== 'Red' && item.Value !== 'Blue';
});
}
else if(val == "Medium") {
$scope.Variant.Specs.Color.Options = $scope.Variant.Specs.Color.Options;
}
Upvotes: 1
Views: 65
Reputation: 51
Create an angular $filter which takes the colors and size as arguments.
app.filter('filterColors', function() {
return function(colors, size) {
if(size=='Medium') {
return colors;
} else {
return colors.filter(function(d) {
return d != 'Red' && d != 'Blue';
});
}
}
});
Upvotes: 1