lundi 28 décembre 2015

Ember BelongsTo within two models issue

Good day all,

Sorry for patience, but have one big trouble with Ember-Data...

I have two models:

  • guild [title, color, players[], owners[], ... ];
  • lessons [title, guild:belongsTo('guild'), ... ];

I want prepare some information for events, in the router (try many another variants) i have next code:

export default Ember.Route.extend({
model() {
    return Ember.RSVP.hash({
        lessons: this.store.findAll('lesson'),
        events: Ember.computed(function(){
            var events = [];
            this.lessons.map(function(lesson){
                events.push({
                    'title': lesson.get('title'),
                    'start': lesson.get('start'),
                    'end'  : lesson.get('end'),
                    'color': lesson.get('guild').get('color') // here i want get color from guild.
                })
            });
            console.log(events);
            return events;
        }).property('lessons')
    });
}});

Another method is compute specific property in the model:

guildColor: Ember.computed('guild', function()....).property('guild')

, also doesn't help :(

Always return UNDEFINED T_T, any help would be appreciate.

Regards, iTux.




Aucun commentaire:

Enregistrer un commentaire