Want to pass parameters with the action Helper of EmberJS? I was thinking something more along the lines of this since you’ll have access to a bunch more through an actual view.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | App = Ember.Application.create(); App.peopleController = Ember.ArrayController.create({ content: [ { name: 'Roy', url: '#' }, { name: 'Mike', url: '#' }, { name: 'Lucy', url: '#' } ] }); App.PersonView = Ember.View.extend({ tagName: 'li', content: null, linkClicked: function() { console.log(this.getPath('content.name')); } }); |
1 2 3 4 5 6 7 8 9 | <ul> {{#each App.peopleController}} {{#view App.PersonView contentBinding="this"}} <a {{bindAttr href="content.url"}} {{action "linkClicked" on="click"}}> {{content.name}} </a> {{/view}} {{/each}} </ul> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.