【发布时间】:2017-09-03 15:58:42
【问题描述】:
我正在完成this Meteor 教程,并且我已经更新了 imports/ui/task.html 以仅向创建它们的用户显示任务,如下所示:
<template name="task">
{{#if isOwner}}
<li class="{{#if checked}}checked{{/if}} {{#if private}}private{{/if}}">
<button class="delete">×</button>
<input type="checkbox" checked="{{checked}}" class="toggle-checked" />
<span class="text">{{text}}</span>
</li>
{{/if}}
</template>
但是,我仍然有显示所有用户任务的不完整计数,我想将其更改为仅登录的用户。这是我认为需要更改的 imports/ui/body.js 的一部分.
Template.body.helpers({
tasks() {
const instance = Template.instance();
if (instance.state.get('hideCompleted')) {
// If hide completed is checked, filter tasks
return Tasks.find({ checked: { $ne: true } }, { sort: { createdAt: -1 } });
}
// Otherwise, return all of the tasks
// Show newest tasks at the top. This is the meat of the thing!
return Tasks.find({}, { sort: { createdAt: -1 } });
},
incompleteCount() {
return Tasks.find({ checked: { $ne: true } }).count();
},
});
【问题讨论】:
-
欢迎来到 SO。请从阅读帮助部分开始,尤其是:stackoverflow.com/help/mcve。不要指望这里的人们阅读本教程只是为了了解您遇到的问题。说明问题中的问题。另外,向我们展示您已经尝试过的内容,而不是您认为必须更改的内容。
标签: meteor