问题
What I need is: 1) Represent list of partners
App.Partner= DS.Model.extend(
{
name: attr(),
site: attr(),
contacts: DS.hasMany('partner-contact', { async: true, polymorphic: true })
}
);
2) and names of partners contacts
App.PartnerContact = DS.Model.extend(
{
name: attr(),
phone: attr(),
post: attr(),
email: attr(),
partnerId: attr(),
partner: DS.belongsTo('partner')
}
);
So I have route:
App.CallsMyContactsRoute = Ember.Route.extend({
//needs: "partner-contacts",
model: function () {
return this.store.find('partner');
}
});
And template:
{{#each partner in model}}
<tr class="gradeA even" role="row">
<td class="sorting_1">{{partner.name}}</td>
<td>{{partner.name}}</td>
<td>{{partner.phone}}</td>
<td class="center">
{{partner.contacts}}
{{#each contact in partner.contacts}}
{{contact.name}}
{{/each}}
</td>
<td class="center">A</td>
</tr>
{{/each}}
But {{partner.contacts}} is DS.PromiseManyArray And it ever doesn't make a query to server.
Answer from server (Partners)
{
"Partner":[
{
"id":4,
"name":"CompanyNamej",
"site":"www.no-site.ru"
},
{
"id":13,
"name":"test",
"site":"sdasdasd"
},
{
"id":14,
"name":"",
"site":""
}
]
}
What is the problem?
DEBUG: Ember : 1.10.0
vendor.js:16928DEBUG: Ember Data : 1.0.0-beta.15
vendor.js:16928DEBUG: jQuery : 2.1.3
来源:https://stackoverflow.com/questions/29213984/relation-is-ds-promisemany-instead-model-and-data