[英]Author of todo in Meteor todoapp
Dears, please advise how to display author for each todo correctly. 亲爱的,请告知如何正确显示每个待办事项的作者。 I added authorId to the Todos collection, made helper and corrected publication, but it doesn't work: I see profile of author in browser, but don't know how to pass the name to todo. 我将authorId添加到Todos集合中,做了帮助并更正了出版物,但它不起作用:我在浏览器中看到作者的个人资料,但不知道如何将名称传递给todo。
I guess that the issue in todoArgs(todo) in https://github.com/meteor/todos/blob/master/imports/ui/components/lists-show.js because todoAuthor isn't passed. 我想todoArgs(todo)中的问题在https://github.com/meteor/todos/blob/master/imports/ui/components/lists-show.js,因为todoAuthor没有通过。
Hope on any help/comment. 希望任何帮助/评论。
todos.js todos.js
Todos.helpers({
todoAuthor: function() {
return Meteor.users.findOne(this.authorId);
}
});
publications.js publications.js
children: [{
find(list) {
return Todos.find({ listId: list._id }, { fields: Todos.publicFields });
},
children: [
{
find: function(username, list) {
return Meteor.users.find(
{ _id: username.authorId },
{ fields: { profile: 1 } });
}
}
]
}],
todos-item.html 待办事项,item.html
<template name="Todos_item">
{{todoAuthor.profile.name}}
</template>
I have found the temporary solution using {{#let}}, but it would be nice to hear best practice on that matter. 我已经使用{{#let}}找到了临时解决方案,但听到关于此问题的最佳实践会很高兴。 Thank you. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.