我有一个复选框列表:
const that = (()=>this)(); // .... (*)
.... .... 我想过滤选中的复选框字段,如下所示:
proc // args {
global step data
set args [lassign $args _ kword]
set val [lindex $args end]
switch -- $kword {
step {
set step $val
}
MK {
dict set data $step MK $val
}
}
}
proc make_XYZ {in out data} {
while {[gets $in line] >= 0} {
if {[regexp {^\s*X_step_(\d+)} $line -> n] && [dict exists $data $n MK]} {
regsub {\(.*\)} $line ([dict get $data $n MK]) line
}
puts $out $line
}
}
rename unknown _unknown
proc unknown args {}
set data {}
source ABC
rename unknown {}
rename _unknown unknown
file rename -force XYZ XYZ.bak
set f1 [open XYZ.bak r]
set f2 [open XYZ w]
make_XYZ $f1 $f2 $data
close $f1
close $f2
任何推入我的数组filterField并过滤多个值的解决方案?谢谢!
答案 0 :(得分:0)
在这种情况下最好使用自定义过滤器
Owls <- read.table(file = "Owls.txt", header = TRUE, dec = ".")
ifelse(Owls$FoodTreatment == "Satiated", Owls$NestNight <- paste(Owls$Nest, "1",sep = "_"), Owls$NestNight <- paste(Owls$Nest, "2",sep = "_"))
答案 1 :(得分:0)
来自AngularJS : Custom filters and ng-repeat
检查多个字段
// Filter, where element would be your x
$scope.filterFn = function(element)
{
if(element.field === 'value1' || element.anotherField === 'value2')
{
return true; // this will be listed in the results
}
return false; // otherwise it won't be within the results
};
然后应用它
x in X | filter:filterFn
答案 2 :(得分:0)
另一种方法是使用一个自定义过滤器并向其添加参数。这个小提示显示了如何使用具有多个参数的过滤器: http://jsfiddle.net/halirgb/Lvc0u55v/
喜欢这个
myApp.filter('customFilter', function() { // Name of filter
return function(first, second,third) {
// write filter code here
return second;// shows the last filter parameter
};});
并像这样使用过滤器:
<div ng-repeat="x in X"> {{x|customFilter:myFilter.filterField}} </div>