Ilia Choly
Ilia Choly

Reputation: 18557

Ember.js {{action}} in {{each}}

Say I have the following template

{{#each item in controller}}
    <a {{action "doSomething" item}}>{{item.name}}</a>
{{/each}}

Now I have the following action defined in the router.

doSomething: function(router, event){
    event.context.get('name');
}

is there anything wrong with accessing the property this way? I'm just asking because I haven't seen this anywhere else.

Upvotes: 3

Views: 748

Answers (1)

Luke Melia
Luke Melia

Reputation: 8389

There's nothing at all wrong with doing that. That's the purpose of the context.

Upvotes: 6

Related Questions