EmberJS Data HasMany关系父JSON包含整个对象而不是ids
App.Message = someParentClass.extend({
childMessages: DS.hasMany('ChildMessage'),
message:DS.attr('string',{defaultValue: ""})
}
App.ChildMessage = someParentClass.extend({
message: DS.attr('string',{defaultValue: ""}),
code:DS.attr('string',{defaultValue: ""})
}
,JSON看起来像这样
{
"message":"xyz",
"childMessages":[{"code":"we","message":""},{"code":"uh","message":""},{"code":"wd","message":""}]
}
获取对象后,子消息的代码和消息未定义(未填充)
不在我手中改变JSON
请帮忙
答案 0 :(得分:0)
问题得到解决。
Ember为每个子对象提供id。所以从服务器我添加了随机数的id文件。
{
"message":"xyz",
"childMessages":[{"id":4567,"code":"we","message":""},{"id":7874,"code":"uh","message":""},{"id":5231,"code":"wd","message":""}]
}
它有效
由于