我在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');
}
});