2017-05-05 33 views
0

即時獲取數據JSON API格式與我RouteEmber DataJSONAPIAdapter - 這是工作的罰款無法顯示包含數據

// 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

你的意見和代碼是矛盾的。你在評論中說,數據正在被抓取,但沒有反映在模板中。

然而,在代碼中,這似乎沒有失敗的獲取數據的第二個呼叫的部分:this.store.findRecord('posts', params.post_id, { include: 'comments' });

確實爲/職位正常的GET請求/ 1 /評論到後端成功返回數據?