Issue
I am able to print the result, how would I return the result here to be assigned to an object
Attribute text is a string that we must split
this.childArrayAll.filter(x => x.attributeText1.split(",").forEach(y => {
if(this.searchFilterForm.controls['types'].value.includes(y) )
console.log(x);
}))
Solution
You can use Array’s some method to do it in clean and optimized way.
this.childArrayAll.filter(x => {
const attributes = x.attributeText1.split(",");
// Check if there is a match
return attributes.some(attribute => this.searchFilterForm.controls['types'].value.includes(attribute));
});
Answered By – dhaker
Answer Checked By – David Marino (BugsFixing Volunteer)