繁体   English   中英

流星todoapp的todo作者

[英]Author of todo in Meteor todoapp

亲爱的,请告知如何正确显示每个待办事项的作者。 我将authorId添加到Todos集合中,做了帮助并更正了出版物,但它不起作用:我在浏览器中看到作者的个人资料,但不知道如何将名称传递给todo。

我想todoArgs(todo)中的问题在https://github.com/meteor/todos/blob/master/imports/ui/components/lists-show.js,因为todoAuthor没有通过。

希望任何帮助/评论。

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 } });
     }
    }
  ]
}],

待办事项,item.html

<template name="Todos_item">
    {{todoAuthor.profile.name}}
</template>

我已经使用{{#let}}找到了临时解决方案,但听到关于此问题的最佳实践会很高兴。 谢谢。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM