Joe*_*ldi 5 json has-many ember.js asp.net-web-api ember-data
使用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")
});
Run Code Online (Sandbox Code Playgroud)
和有效载荷如:
/ API /日历/ 1:
{
"calendar": {
"id": 1,
"reservations": [],
"links": {
"reservations": "/api/calendar/1/reservations"
}
}
}
Run Code Online (Sandbox Code Playgroud)
/ API /日历/ 1 /保留:
{
"reservations": [
{
"id": 1,
"date": "10/01/2014"
}
]
}
Run Code Online (Sandbox Code Playgroud)
为什么Calendar模型上的预留数组没有延迟加载?
您的 json 不应定义两次保留
{
"calendar": {
"id": 1,
"links": {
"reservations": "/api/calendar/1/reservations"
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
978 次 |
| 最近记录: |