Angular (click) - multiple functions?

github logo ・1 min read

-> on click of a button you need to check data from two functions with (click) attribute.

Do you :
A) create a third function which encapsulates the two & pass that in the (click).
Example : (click)="thirdFunction()"
B) you pass both of them.
Example :
(click)="first(); second();"

What seems to be the best practice for you?

twitter logo DISCUSS (2)
markdown guide

I would go with Option A, call it on[Whatever]Click(). That way there is a single click handler for the output and you're less likely to have unintended side-effects.

Classic DEV Post from Mar 6

7 Tips for Breaking Into DevRel

How to get into developer advocacy & relations.

KristijanFiĆĄtrek profile image
I love to code.