使用 在应用程序中给定两个模型DS.RESTAdapter :
App.Calendar = DS.Model.extend({
reservations: DS.hasMany("reservation", { async: true })
});
App.Reservation = DS.Model.extend({
date: DS.attr("date"),
calendar: DS.belongsTo("calendar")
});
以及有效载荷,例如:
/api/calendar/1:
{
"calendar": {
"id": 1,
"reservations": [],
"links": {
"reservations": "/api/calendar/1/reservations"
}
}
}
/api/calendar/1/reservations:
{
"reservations": [
{
"id": 1,
"date": "10/01/2014"
}
]
}
为什么预订 上的数组日历 模型没有被延迟加载?
最佳答案
你的 json 不应该有两次定义的保留
{
"calendar": {
"id": 1,
"links": {
"reservations": "/api/calendar/1/reservations"
}
}
}
关于json - Ember 数据 : Using "links" on JSON payload for hasMany relationships,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25727650/