ember.js - Get object from belongsTo relationship -


let's have model like:

app.employee = ds.model.extend({   name: ds.attr('string'),    department: ds.belongsto('app.department')     }); 

in controller can say

var name = thisemployee.get('name'); 

but can't say

var department = thisemployee.get('department'); 

so question how reference object on other side of relationship.

i assume problem lies in fact maybe don't have specified how relationships should load... try setting adapter map this:

app.adapter.map('app.employee', {   department: {embedded: 'always'} }); 

this should side load department relationships automatically on requesting parent model employee e.g. app.employee.find();.

hope helps


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -