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.
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.
Hope on any help/comment.
todos.js
Todos.helpers({
todoAuthor: function() {
return Meteor.users.findOne(this.authorId);
}
});
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
<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. Thank you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.