Binding a function to a button is easy and straightforward:
<button on:click={handleClick}> Clicks are handled by the handleClick function!</button>
But I don't see a way to pass parameters (arguments) to the function, when I do this:
<button on:click={handleClick("parameter1")}> Oh no!</button>
The function is called on page load, and never again.
Is it possible at all to pass parameters to function called from on:click{}
?
I found the proper way to do it (see comments). Calling the function from an inline handler works.
<button on:click={() => handleClick("parameter1")}> It works...</button>