Passing Function Arguments in the Angular Template Declaration | Task

Ole Ersoy
Feb - 16  -  1 min

Scenario

We have a template declaration that invokes the components log function and we wish to pass different values to log().

Approach

Simply pass the function argument, as is done in the below demo like this:

<button (click)="log('hola!')">Log Hola!</button>
<button (click)="log('hello!')">Log Hello!</button>

Demo