【问题标题】:helpers result not passed to template in Meteor助手结果未传递给 Meteor 中的模板
【发布时间】:2016-01-22 01:13:40
【问题描述】:

我有一个小助手,它通过在服务器端调用我的方法来计算平均值。

Template.replyDoc.helpers({
    averageVote : function(userId){
        var question = Template.parentData();
        Meteor.call("averageVote",question._id,userId,function(error,result){
            console.log('average: ' + result);
            return result;
        });
    }
});

然后我试图在我的模板中呈现我的助手结果:

<template name="replyDoc">
    <div class="list-group-item">
        AVERAGE:{{averageVote userID}}
    </div>
</template>

平均值计算正确,因为 console.log 工作正常,但我看不到它呈现。请问为什么会这样,应该怎么解决?

【问题讨论】:

    标签: meteor


    【解决方案1】:

    我设法找到了答案;meteor methods inside helper

    我使用了简单的反应式方法,它奏效了。

    【讨论】:

      猜你喜欢
      • 2015-09-02
      • 2015-09-30
      • 2015-07-10
      • 1970-01-01
      • 1970-01-01
      • 2016-01-07
      • 2015-01-06
      • 1970-01-01
      • 2015-08-25
      相关资源
      最近更新 更多