Thursday, 22 August 2013

Ember Data hasMany foreach within controller

Ember Data hasMany foreach within controller

I currently have the following models setup using Ember Data and the Local
storage adaptor.
App.Game = DS.Model.extend
stage: DS.attr('number')
level: DS.attr('number')
actions: DS.hasMany('App.Action')
App.Action = DS.Model.extend
type: DS.attr('string')
time: DS.attr('number')
game: DS.belongsTo('App.Game')
I can access each action from within the template using


But I would like to access this same data from within the controller.
Is there are any to do this?
The following returns the actions length but I'd like to forEach over each
action.
actionsLength: (->
@get('actions').get('length')
).property('actions.@each')
Any help would be appreciated.

No comments:

Post a Comment