使用 and 子句过滤数据并使用大于运算符
filter data using and clause and using greater then operator
我一直在 angularjs 中使用 $filter
,它非常好。现在我得到了一个需要过滤的要求,它必须是一个 and 子句。而且我需要在过滤时也能够使用大于符号。我有像
这样的对象
var filterBy = {gender: "Male", location: "50", focus: "true", yearsOfCoaching: ">2"};
$filter('filter')(data, filterBy);
在这种情况下 >2
行得通吗?这是使用 and 子句的正确格式吗?
您可以使用 angular-过滤器库 (https://github.com/a8m/angular-filter#pick) 的 'pick' 过滤器:
$filter('pick')(data, function(elem){
return elem>2;
});
我一直在 angularjs 中使用 $filter
,它非常好。现在我得到了一个需要过滤的要求,它必须是一个 and 子句。而且我需要在过滤时也能够使用大于符号。我有像
var filterBy = {gender: "Male", location: "50", focus: "true", yearsOfCoaching: ">2"};
$filter('filter')(data, filterBy);
在这种情况下 >2
行得通吗?这是使用 and 子句的正确格式吗?
您可以使用 angular-过滤器库 (https://github.com/a8m/angular-filter#pick) 的 'pick' 过滤器:
$filter('pick')(data, function(elem){
return elem>2;
});