mercredi 9 août 2017

Ember.js: compute a nested relationship as a model property

I currently have three models, Model, Manufacturer, and Device: A Model belongs to a Manufacturer, and a Device belongs to a Model. However, when I list the devices, I'd also like an entry for the manufacturer. I know I can fetch it easily with model.model.manufacturer.name, however, I'd like Device to have it's own manufacturer property. I have looked into Ember's computed properties, however, I can't seem to find a way to compute the model's manufacturer as the device's property, e.g.:

manufacturer: Ember.computed('manufacturer', function () {
  return this.belongsTo('model').manufacturer
})

That's what I'm aiming for, but it doesn't work. Is this even possible at all?

Thank you!




Aucun commentaire:

Enregistrer un commentaire