我有一个简单的消息传递应用程序的以下数据结构:
App.Message = DS.Model.extend({
title: DS.attr("string"),
body: DS.attr("string"),
isRead: DS.attr("boolean"),
replyTo: DS.belongsTo("App.Message")
});
App.Message.FIXTURES = [{
id: "1",
title: "Eos ut amet persius, ea ius nibh iudico",
body: "Lorem ipsum dolor sit amet, nam et hinc doctus alienum, in vel latine conceptam.",
isRead: true,
replyTo: null
},
{
id: "2",
title: "Ad est dolor veniam delenit.",
body: "Lorem ipsum dolor sit amet, nam et hinc doctus alienum, in vel latine conceptam.",
isRead: false,
replyTo: "1"
},
{
id: "3",
title: "Eu nec summo placerat reprehendunt.",
body: "Lorem ipsum dolor sit amet, nam et hinc doctus alienum, in vel latine conceptam. Tale eirmod omittantur sit ne. Minim noster philosophia per eu, mel putent veritus an, ex veniam ubique consulatu has. At stet diceret repudiare ius, probo liber diceret no est. Ridens efficiantur vim te.",
isRead: false,
replyTo: "1"
}];
我正在尝试显示对邮件的回复但是没有显示回复。邮件主题和正文 显示正常,所以我知道我的路由,控制器和模板至少为父实体正确设置。
以下是我的模板(为简洁起见,删除了几乎所有标记):
<script type="text/x-handlebars" data-template-name="message">
<h2>{{ title }}</h2>
<p>{{ body }}</p>
{{ render "messageResponses" responses }}
</script>
<script type="text/x-handlebars" data-template-name="messageResponses">
{{#each responses}}
<p>{{ body }}</p>
{{/each}}
</script>
我的消息控制器(我可能做错的部分):
App.MessageController = Ember.ObjectController.extend({
responses: function() {
return App.Message.find({ replyTo: this.get("id") );
}
});
答案 0 :(得分:1)
请尝试findProperty
:
App.MessageController = Ember.ObjectController.extend({
responses: function() {
return App.Message.findProperty('replyTo', this.get("id"));
}
});