AngularJS-在拆卸/清理过滤器时卡住
我在下拉列表上应用了一个过滤器,但我希望根据另一个下拉列表值将其删除。代码如下。如果用户选择“中”(或任何其他值),那么我需要删除当用户选择“小”时应用的过滤器。现在,如果用户选择“小”然后选择“中”,这些选项仍然会被过滤掉AngularJS-在拆卸/清理过滤器时卡住,angularjs,Angularjs,我在下拉列表上应用了一个过滤器,但我希望根据另一个下拉列表值将其删除。代码如下。如果用户选择“中”(或任何其他值),那么我需要删除当用户选择“小”时应用的过滤器。现在,如果用户选择“小”然后选择“中”,这些选项仍然会被过滤掉 if(val == "Small"){ $scope.Variant.Specs.Color.Options = $scope.Variant.Specs.Color.Options.filter(function(item) { return item.Value
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;
}
创建一个以颜色和大小为参数的角度$过滤器
app.filter('filterColors', function() {
return function(colors, size) {
if(size=='Medium') {
return colors;
} else {
return colors.filter(function(d) {
return d != 'Red' && d != 'Blue';
});
}
}
});
看看这个:我不知道你的问题的答案,但这似乎是你想要的。这非常有用!谢谢!:-)