我有一个html表的管道过滤器
#include<iostream>
using namespace std;
class one;
class two;
class one
{
int a = 10;
public:
friend int cal(one a,two b);
};
class two
{
int b = 20;
public:
friend int cal(one a,two b);
};
int cal(one x,two y)
{
return (x.a>y.b)?x.a:y.b;
}
int main()
{
one x;
two y;
cout << cal(x,y);
}
如何使用条件从html代码diferentes params发送过滤:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({name: 'filterDescrip'})
export class FilterDescripPipe implements PipeTransform {
transform(particulars: any, searchText: any): any {
if(searchText == null) return particulars;
return particulars.filter(function(particular){
if(searchText.match(/[a-z]/g))
{
return particular.description.toLowerCase().indexOf(searchText) > -1;
} else {
return particular.description.toUpperCase().indexOf(searchText) > -1;
}
//return particular.description.toLowerCase().indexOf(searchText) > -1;
})
}
}
我可以使用以下条件:| filterDescrip:{},也许有一个表达式,怎么会?
我有两个变量,我需要以下内容:如果变量paramSearch为空或未定义:
<tr *ngFor="let particular of particulars | filterDescrip: paramSearch | orderBy: {property: column, direction: direction}">
但如果paramSearch有内容:
| filterDescrip: searchDescText
谢谢,
答案 0 :(得分:1)
试试这个:
<tr *ngFor="let particular of particulars | filterDescrip: (paramSearch || searchDescText) | orderBy: {property: column, direction: direction}">