{
"id":805,
"name":'test',
"Email":[
{
"Name":"name1",
"Email":"[email protected]"
},
{
"Name":"name2",
"Email":"[email protected]"
}
..
..
],
"createdDate":"..."
},
{
"id":806,
"name":'test',
"Email":[
{
"Name":"name1",
"Email":"[email protected]"
},
{
"Name":"name2",
"Email":"[email protected]"
}
..
..
],
"createdDate":"..."
}
this.data=this.data.filter((item=> this.selectedId.includes(item.id)));
where this.selectedId = [‘805′,’806’]
let email='[email protected]';
if Email
contains this [email protected]
then that data also we need to show.
this.data=this.data.filter((item=> this.selectedId.includes(item.id)) || Object.keys(item.Email).includes(email));
2
Answers
Your syntax is incorrect for the lambda expression/function.
While you can use the
.find()
with double negation (!!
) to indicate theEmail
filter returns value.Or with
.findIndex()
Note that with
selectedId = ['805','806']
, you will get the incompatible error as theid
s provided in yourdata
array areNumber
.