javascript - Meteor todoapp 中 todo 的作者

标签 javascript meteor

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

我猜想 https://github.com/meteor/todos/blob/master/imports/ui/components/lists-show.js 中的 todoArgs(todo) 中的问题因为 todoAuthor 未传递。

希望得到任何帮助/评论。

tod​​os.js

Todos.helpers({
   todoAuthor: function() {
      return Meteor.users.findOne(this.authorId);
   }
});

出版物.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 } });
     }
    }
  ]
}],

tod​​os-item.html

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

最佳答案

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

关于javascript - Meteor todoapp 中 todo 的作者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39810308/

相关文章:

javascript - 水平溢出/Text Inside Span 嵌套在 Div 中

mongodb - MeteorD中的MongoDB URL

javascript - to$q 的 typescript 定义文件

javascript - 重置数据 Meteor 方法

css - meteor :使用MyFonts中的@ font-faces让Safari立即崩溃

javascript - Meteor 中的附加订阅

javascript - 如何使用jquery检索单选按钮内选择标签中的值?

javascript - 文本区域干扰 Ajax 代码

javascript - 如何在父组件中单击按钮时控制该子组件的状态?

javascript - 我已经有了 Money abbreviater,但不知道如何制作它,以便它显示 $1.05k 等