I am faced with a problem and I don’t understand how I can solve it.
I have a service where I return the following JSON:
{
"data": [
{
"data": 179,
"data_form": "Finished - Form Covid-19 Test 1",
"form": 144,
"user": 1,
"status": "Finished"
},
{
"data": 176,
"data_form": "Form Covid-19 Test 2",
"form": 144,
"user": 1,
"status": "In process"
},
{
"data": 177,
"data_form": "Finished - Form Covid-19 Test 3",
"form": 144,
"user": 1,
"status": "In process"
},
{
"data": 178,
"data_form": "Finished - Form Covid-19 Test 4",
"form": 144,
"user": 1,
"status": "In process"
}
]
}
I am using a PIPE where I am sending it my array, the value I want to filter and the column where that value is:
<ion-list
*ngFor="let form of forms | filter: searchValue: ['status','data_form']">
<app-form-user [form]="form">
</app-form-user>
</ion-list>
It works if I indicate the column:
return array.filter(
//It works
item=> item[column[0]].toLowerCase().includes( text )
);
The idea is to look for the value in all the columns that you indicate to the pipe, I tried the following:
1.
return array.filter(
item=> item[column.forEach((data) => found = data )].toLowerCase().includes( text );
);
return array.filter(
item=>Object.keys(column).every(key =>
item[key] == column[key]
)
);
return array.filter(
item=> column.forEach((data) => item[data].toLowerCase().includes( text ))
);
I hope you can help me, thank you.