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