我是ember的新手,我正在通过DS.RESTAdapter()
撤回一些JSON,如下所示:
{"apis":[{"id":"0",name:"test",methods:[{"id":"0","name":"test"},{"id:"1","name":"test2"}]}]}
我的模特:
App.Api = DS.Model.extend({
name: DS.attr('string'),
methods: DS.hasMany('App.ApiMethod')
});
App.ApiMethod = DS.Model.extend({
api: DS.belongsTo('App.Api'),
name: DS.attr('string')
});
我可以很好地阅读Api
模型属性,但是如果我尝试遍历methods属性,它就是空的。我还尝试在{ embedded: true }
电话中传递DS.hasMany()
作为选项。
有什么想法吗?
答案 0 :(得分:0)
您没有使用嵌套模型的默认休息格式 - > http://emberjs.com/guides/models/the-rest-adapter/#toc_sideloaded-relationships