jeudi 2 mars 2017

Destructuring Objects Passed as Ember Action Arguments

Official Ember Guide about actions emphasizes that destructuring objects passed as action arguments is possible with the use of value named parameter within the action helper. My problem is that this scenario works only for the first argument but fails for the remaining arguments of the action.

Please see the twiddle I have prepared to illustrate the case. In this simple twiddle, my-component triggers an action after button click and the application controller handles the action. As can be seen within application.hbs I declared the action as (action 'actionHandler' value='name'); this means I want the name fields of the action arguments to be sent to the action handler within application.js. However as can be seen from the alerts displayed; the value parameter is working for the first argument of the action (john is displayed as expected); but fails for the second argument (jack is not retrieved as the second argument of the action handler; but the whole object retrieved).

My question is; is there a way to destructure the arguments after the first one? If it is possible, can I vary the properties to be extracted among argument, i.e. name of first argument, id of second argument and so on.




Aucun commentaire:

Enregistrer un commentaire