我使用JSON API
上的Ember Data
和JSONAPIAdapter
以Route
格式提取数据 - 这很正常
// ok
/posts/1
this.store.findRecord('posts', params.post_id);
我现在正试图使用ds-finder-include
加载包含的数据,数据已被提取,但未反映在.hbs
https://www.emberjs.com/blog/2016/05/03/ember-data-2-5-released.html#toc_code-ds-finder-include-code
// not working
/posts/1/comments
this.store.findRecord('posts', params.post_id, { include: 'comments' });
HBS:
{{#each post.comments as |comment index|}}
comment: {{comment}}
{{/each}}
答案 0 :(得分:0)
您的评论和代码是矛盾的。您在评论中说,数据已被提取但未反映在模板中。
但是,在代码中,似乎没有失败的部分是获取第二个调用的数据:this.store.findRecord('posts', params.post_id, { include: 'comments' });
对您的后端的 / posts / 1 / comments 的正常GET请求是否成功返回数据?