如何将多个参数传递到 Ui-AngularJs 中的网格过滤器
How to pass multiple parameters into Ui-grid filter in AngularJs
我在 AngularJs UI-grid 中创建了一个自定义过滤器。过滤器在使用单个参数时工作正常,但是当涉及到多个值时过滤器不起作用 well.Please 如果任何人都知道如何将多个参数传递到 UI 网格过滤器让我知道。
AngularJs 过滤方法
点击按钮时执行过滤器,并根据用户名重新绘制网格。
$scope.filterData = function(userName) {
$scope.searchText = userName;
$scope.tableData.data = $filter('filter')
($scope.TestData,
$scope.searchText, undefined);
//how can i pass multiple param into filter like filtering based on user name and age
};
传递任意数量的参数。但是在使用过滤器标签时,使用函数而不是单个参数。
参考下面的代码。
$scope.filterData = function(userName, secndParm, thirdParm,...) {
$scope.tableData.data = $filter('filter')
($scope.TestData, function (value, key) {
return (value.userName == userName || value.someText == secndParm || value.someAntherText == thirdParm);
});
}
我在 AngularJs UI-grid 中创建了一个自定义过滤器。过滤器在使用单个参数时工作正常,但是当涉及到多个值时过滤器不起作用 well.Please 如果任何人都知道如何将多个参数传递到 UI 网格过滤器让我知道。
AngularJs 过滤方法
点击按钮时执行过滤器,并根据用户名重新绘制网格。
$scope.filterData = function(userName) {
$scope.searchText = userName;
$scope.tableData.data = $filter('filter')
($scope.TestData,
$scope.searchText, undefined);
//how can i pass multiple param into filter like filtering based on user name and age
};
传递任意数量的参数。但是在使用过滤器标签时,使用函数而不是单个参数。
参考下面的代码。
$scope.filterData = function(userName, secndParm, thirdParm,...) {
$scope.tableData.data = $filter('filter')
($scope.TestData, function (value, key) {
return (value.userName == userName || value.someText == secndParm || value.someAntherText == thirdParm);
});
}