Reputation: 1121
Question about searching values from array into another array. Example of arrays:
items = [{"name":"Goran", "category":[0:3, 1:5]}, {"name":"Marko", "category":[0:5, 1:4]}]
arr1 = ["5", "4", "3"]
Typescript try:
let result = items.filter(item => arr1.find(f => f == items.category))
and the result is none. Can you give me hint how can I do this in one line of code. Basically this is filter from template. I you can image an array of checkbox checking the values from json object. So I want to find values where from arr1 in object items.
Upvotes: 0
Views: 277
Reputation: 58573
Try to use index of :
let result = items.filter(item => {
return arr1.indexOf(items.category) > -1
})
Upvotes: 1