Difference in action helper


Can someone point out the difference between

<button onClick={{action ‘actionName’}} > and <button {{action ‘actionName’}} ?


In most cases, these will do the same thing. The first one will actually get the event as the first argument, so if you need access to the native event object, you need to use that notation.

The second one is actually equivalent to

<button {{action 'doSomething' on='click'}}>

Where on could also be e.g. submit to react to other events.

Really, apart from style the only difference between these two are the arguments given to the action.


Thanks, I get that. @francesconovy. Is there any preferred method or best practices while doing these ?


There’s actually a bit more difference than that. See https://www.youtube.com/watch?v=G9hXjjHFJVs