How to pass arguments in arrow functions in typescript

191 views Asked by At

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?

1

There are 1 answers

0
Reactgular On BEST ANSWER

You can use the [] property access operator.

return value.filter(contact => contact[field] === id)