我无法输出与 hasMany 相关的数据
楷模:
App.Album = DS.Model.extend({
title: DS.attr('string'),
index: DS.attr('number'),
preview: DS.attr('string'),
preview_uri: DS.attr('string'),
create_time: DS.attr('date'),
update_time: DS.attr('date'),
photos: DS.hasMany('photo'),
});
App.Photo = DS.Model.extend({
file: DS.attr('string'),
index: DS.attr('number'),
file_uri: DS.attr('string'),
update_time: DS.attr('date'),
create_time: DS.attr('date'),
albums: DS.hasMany('album')
});
模板:
<script type="text/x-handlebars" data-template-name="albums">
{{#each}}
<div><img {{bind-attr src=preview_uri}}></div>
<div>{{id}}#{{title}}</div>
{{#each photos}}
<div style="margin-left: 40px;">
<div><img {{bind-attr src=file_uri}}></div>
<div>{{id}}</div>
</div>
{{/each}}
{{/each}}
</script>
专辑 json:
{
"albums":[
{
"id":"1",
"title":"album1",
"preview":"filexx",
"create_time":"2013-09-13 22:18:56",
"update_time":"2013-09-13 22:40:57",
"index":"0",
"photo_ids":[
"1"
],
"preview_uri":"\/uploads\/fi\/le\/xx\/f.png"
}
]
}
我正在使用标准的 RESTAdapter。转换后,它会正确加载相册并渲染它们,但没有照片,我做错了什么?
看来,与旧版本的 ember-data 相关的所有类似问题,我正在使用 v1.0.0-beta.2