Angular UI-严格匹配的网格过滤
Angular UI-Grid filtering by strict match
我正在用 Angular UI-Grid 创建一个 table,我想通过严格匹配过滤 table 内容。默认情况下 "Car" 输入将与 "Carol" 匹配,但我希望 UI-Grid 的过滤仅在输入等于 table 条目时才匹配。
做一个过滤方法。而不是 ng-repeat="x in items|filter:filterVariable"
使用过滤方法。在您的控制器代码中输入:
var myFilter = function(x){
return x == $scope.filterVariable;
}
而 ng-repeat
看起来像:
ng-repeat="x in items | filter:myFilter"
试试这个
{
field: 'email',
filter: {
condition: uiGridConstants.filter.EXACT,
placeholder: 'your email'
}
}
尝试 uiGridConstants.filter.EXACT 导致同时获取 CAR 1、CAR 2。
如果只想获取 "CAR",不包括 "CAR 1" 和 "CAR 2",使用函数会很有用:
{ field: 'name', width :'150', filter: {
condition: function(searchTerm, cellValue) {
if (searchTerm === cellValue)
return -1;
else
return 0;
}
}
}
我正在用 Angular UI-Grid 创建一个 table,我想通过严格匹配过滤 table 内容。默认情况下 "Car" 输入将与 "Carol" 匹配,但我希望 UI-Grid 的过滤仅在输入等于 table 条目时才匹配。
做一个过滤方法。而不是 ng-repeat="x in items|filter:filterVariable"
使用过滤方法。在您的控制器代码中输入:
var myFilter = function(x){
return x == $scope.filterVariable;
}
而 ng-repeat
看起来像:
ng-repeat="x in items | filter:myFilter"
试试这个
{
field: 'email',
filter: {
condition: uiGridConstants.filter.EXACT,
placeholder: 'your email'
}
}
尝试 uiGridConstants.filter.EXACT 导致同时获取 CAR 1、CAR 2。
如果只想获取 "CAR",不包括 "CAR 1" 和 "CAR 2",使用函数会很有用:
{ field: 'name', width :'150', filter: {
condition: function(searchTerm, cellValue) {
if (searchTerm === cellValue)
return -1;
else
return 0;
}
}
}