Javascript Angularjs ng与筛选器作用域对象重复
我需要根据Javascript Angularjs ng与筛选器作用域对象重复,javascript,jquery,angularjs,Javascript,Jquery,Angularjs,我需要根据$scope.filterObject中的内容筛选ng repeat中的行。我在$scope.customerData中有一个包含所有客户信息的数据,但是当循环遍历每个客户时,我只想根据$scope.filterObject中的内容显示结果。例如,仅显示作业位于$scope.filterObject中的客户行 这是JSFiddle 以下是我到目前为止的情况: HTML: \ 非常感谢您的任何建议和帮助。:) $scope.customerData=data.filter(函数(用户)
$scope.filterObject
中的内容筛选ng repeat
中的行。我在$scope.customerData
中有一个包含所有客户信息的数据,但是当循环遍历每个客户时,我只想根据$scope.filterObject
中的内容显示结果。例如,仅显示作业位于$scope.filterObject
中的客户行
这是JSFiddle
以下是我到目前为止的情况:
HTML:
\
非常感谢您的任何建议和帮助。:)
$scope.customerData=data.filter(函数(用户){
var=false;
$scope.filterObject.forEach(函数(过滤器){
if(filter.Job==user.Job)
发现=真;
})
发现退货;
});代码>
$scope.customerData=data.filter(函数(用户){
var=false;
$scope.filterObject.forEach(函数(过滤器){
if(filter.Job==user.Job)
发现=真;
})
发现退货;
});代码>您可以在ng repeat中使用角度函数比较customerArray和customerObject,然后只返回与customerObject属性匹配的元素
//Instead of array
$scope.filterObject = {
"Job": "CPA"
};
HTML:
<tr ng-repeat="customer in customerData | filter: filterObject">
});
});
HTML:
<tr ng-repeat="customer in customerData | customerFilter: filters">
此处的工作示例:您可以在ng repeat中使用角度函数来比较customerArray和customerObject,然后只返回与customerObject属性匹配的元素
//Instead of array
$scope.filterObject = {
"Job": "CPA"
};
HTML:
<tr ng-repeat="customer in customerData | filter: filterObject">
});
});
HTML:
<tr ng-repeat="customer in customerData | customerFilter: filters">
这里的工作示例:Nedev,谢谢您的回答。我也会查看自定义过滤器。内德夫,谢谢你的回答。我还将查看自定义过滤器。
$scope.filters = {
"Job" :["Technician","CPA"]
}