【发布时间】:2015-07-25 17:25:27
【问题描述】:
我在 Meteor 中有一个包含一些嵌套模板的模板:
<template name="collectingTmpl">
{{> firstTmpl}}
{{> secondTmpl}}
</template>
如果我在firstTmpl 中设置了一个反应变量/字典
Template.firstTmpl.events({
'click .class-name': function(event, template) {
template.state = new ReactiveDict;
template.state.set('someName', 'someValue');
}
});
我可以在同一个模板中得到这个值
Template.firstTmpl.helpers({
myValue: function() {
Template.instance().state.get('someName');
}
});
但是我也可以从secondTmpl 中检索firstTmpl 中设置的值吗?
我的意思是像
Template.secondTmpl.helpers({
myValueFromAnotherTmpl: function() {
Template.firstTmpl.state.get('someName');
}
});
【问题讨论】:
标签: javascript node.js meteor