在我的控制器中,我想过滤一个对象数组.这些对象中的每一个都是一个可以包含字符串和列表的映射
我尝试使用$filter('filter')(array, function)
格式,但我不知道如何访问我的函数内的数组的各个元素.这是一个显示我想要的内容的片段.
$filter('filter')(array, function() {
return criteriaMatch(item, criteria);
});
Run Code Online (Sandbox Code Playgroud)
然后在criteriaMatch()
,我会检查每个属性是否匹配
var criteriaMatch = function(item, criteria) {
// go thro each individual property in the item and criteria
// and check if they are equal
}
Run Code Online (Sandbox Code Playgroud)
我必须在控制器中完成所有这些操作并编译列表列表并在范围内设置它们.所以我确实只需要以$filter('filter')
这种方式访问.到目前为止,我在网络中找到的所有示例都在函数内部进行静态条件搜索,它们不传递条件对象并对数组中的每个项目进行测试.