因此,我收集了包含以下字段的文档(id,usera,userb,message)。 (文档名称室)现在我想根据登录用户命名一个房间。即如果我是用户,我想要显示userb,反之亦然。我有下面的代码,它似乎一直只输出userb。任何建议将不胜感激。
<template name="rooms">
<h4>Contacts:</h4>
<ul>
{{#each rooms}}
{{> room}}
{{/each}}
</ul>
<template name="room">
<li style="cursor: pointer; {{roomstyle}}">
{{#if useraIs}}
{{userb}}
{{/if}}
</li>
});
Template.room.helpers({
useraIs: function(usera) {
return this.usera==Meteor.userId();
}
});