我有一个搜索框,我希望过滤器同时检查skuname和osname,但在搜索单个文件时工作正常我想用这两个组合进行搜索
<input type="text" class=" search-query form-control" ng-model="lansearch" placeholder="Search" />
<tr ng-repeat-start="detail in details | filter: lansearch ">
<td >
<div style="margin-top:5px">
<a class="ng-binding" ng-bind="(detail.skuname)+'' +' '+'' +(detail.osname)"> </a>
</div>
</td>
答案 0 :(得分:0)
您只需要指定要查找的对象,如下所示:这将与AND运算符一样工作。
<tr ng-repeat="detail in details | filter: {skuname: lansearch, osname: lansearch} ">
另一个选项可能是一个函数:
在您的控制器内:
$scope.filterFunction= function(user){
return user.skuname=== $scope.lansearch||
user.osname=== $scope.lansearch;
};
然后在你的html中添加过滤功能:
ng-repeat="detail in details | filter: filterFunction