我有以下父模板:
<template name="parentTempl">
{{#each child}}
{{> childTempl}}
{{/each}}
</template>
我想在childTempl
中访问父数据上下文:
Template.childTempl.rendered = function() {
console.log(this.parent.data); // ?
};
我该怎么做?非常感谢您的任何帮助。
我有以下父模板:
<template name="parentTempl">
{{#each child}}
{{> childTempl}}
{{/each}}
</template>
我想在childTempl
中访问父数据上下文:
Template.childTempl.rendered = function() {
console.log(this.parent.data); // ?
};
我该怎么做?非常感谢您的任何帮助。
Template.parentData(1)._id
时,会出现此错误:错误:没有当前视图
。 - user3475602Template.parentData(1)._id
放在了错误的上下文中。非常感谢! - user3475602