2
我切换到流量路由器并出现问题。我如何访问父模板数据?与铁路由器的数据来自路由器,并在模板内部可用,所以如果我想访问父数据Template.parentData()正在工作。 但在流量路由器中,数据不是来自路由器,而是来自助手,Template.parentData()中没有数据!使用流量路由器访问父级模板数据
<template name="myTemplate">
{{#if Template.subscriptionsReady}}
{{> showPost parentPost }}
{{> newPost }}
{{/if}}
</template>
Template.myTemplate.helpers({
parentPost: function(){ return Posts.findOne({...})}
});
Template.newPost.events({
'submit .js-new-post':function(event,template){
console.log(Template.parentData(1).parentPost);
}});
感谢小费,但通过命名它,它只是获得命名的子模板(newPost)和父模板还是不包括数据! – koolaang
然后,您没有将正确的数据传递给子模板。 –
你看过代码吗?我的问题不是数据不是在儿童中可用,问题是数据不可用在与parentData() – koolaang