I have the following (simplified for this example) data model.
// org.js
export default DS.Model.extend({
profile: DS.belongsTo('organizations/profile',{ async: true }),
});
// profile.js
export default DS.Model.extend({
orgName: DS.attr('string'),
address: DS.belongsTo('address',{ async: true}),
org: DS.belongsTo('organizations/org',{ async: true}),
});
// address.js
export default DS.Model.extend({
address1: DS.attr('string')
});
I’d like to create an object after loading the org which will contain computed properties based on the nested async data model. Something like this:
var Marker = Ember.Object.extend({
id: Ember.computed.alias('org.id'),
title: Ember.computed.alias('org.profile.orgName'),
lat: Ember.computed.alias('org.profile.address.lat'),
lng: Ember.computed.alias('org.profile.address.lng'),
isDraggable: false
});
return orgs.map(function(org) {
return Marker.create({ org: org })
});
This seems to work ok for the title, but for the nested address fields I always get undefined
. I think that ideally the Ember.computed.alias
helper should just work for nested PromiseObject
s but since it doesn’t the only way I can think to do this is to manually wire up then
to the profile and address.