
The arguments can be passed to an action handler with the help of {{action}} helper. These values passed with this helper will be passed as arguments to the helper.
Syntax
<button {{action "action-name" argument}}>Click</button>
Example
The example given below shows passing arguments to the action handler. Create a new route and name it as actionparam.js with the following code −
import Ember from 'ember'; export default Ember.Route.extend ({ actions: { //passing the 'user' as parameter to the User function User: function (user) { document.write('Welcome.. To Adglob'); } } });
Open the actionparam.hbs file created under app/templates/ with the following code −
//passing the 'user' as parameter to a button <button {{action "User" user}}>Click Here </button> {{outlet}}
Output
Run the ember server; you will receive the following output −

Now you click on the button, the User action handler will be called with an argument containing the “user” model.
Previous Page:-Click Here