【发布时间】:2016-05-13 17:05:58
【问题描述】:
我有一个 Meteor 项目,为每个用户设置了个人资料页面系统,这是我在 question 的帮助下创建的。
如何在我的 Template.helpers 的 JS 代码中从该页面的用户个人资料中检索信息?
例如。我的个人资料页面有以下助手
Template.profile.helpers({
winLoseRatio: function() {
var wins = 0;
var losses = 0;
var ratio = wins/losses;
ratio = Math.round((ratio * 1000) + 0.000001) / 1000;
return ratio;
},
totalGuesses: function() {
var wins = 0;
var losses = 0;
var total = wins + losses;
return total;
}
});
对于所有 0 的值,我想获取用户(我所在的个人资料)的 .profile.stats.wins 和 .profile.stat.losses 字段值。
我尝试了Meteor.userId().profile.stats.wins,但返回的是当前登录的您的胜率,而不是拥有个人资料页面的用户的胜率。
【问题讨论】:
标签: meteor field router helpers