i am trying to implement a custom pipe/
transform(value: any, id?: number, field?:string): any {
if(value)
{
return value.filter(contact=>contact.ContactType===id)
}
}
and im calling it from html like this
*ngFor="let mailingContact of facilityContacts | contactFilter:1:'ContactType'"
here i will get the value'1' in id parameter and im setting it to arrow function directly. but i wanna change the ContactType in contact.ContactType with the parameter field name too.
is there any way to achieve it?
You can use the []
property access operator.
return value.filter(contact => contact[field] === id)