2014-11-20 128 views
0

我已经发布了countries收藏品,我想在countriesList模板的表格中展示。所以,我已经加入这个路由器:收藏夹没有显示在页面

Router.route('/countries_list', { 
    name: 'countriesList', 
    waitOn: function() { 
    return Meteor.subscribe('countries'); 
    }, 
    data: function() { 
    return Countries.find(); 
    } 
}); 

这是模板的样子:

{{#each countries}} 
    <tr> 
     <td>{{name}}</td> 
    </tr> 
    {{/each}} 

但页面保持为空。然而,收集填充在客户端上,如果我检查浏览器控制台,并做Countries.findOne();,我得到这样的结果:

Object {_id: "WWJhMBne4CiEdbbdg", name: "England"} 

那我错在这里做什么?

+0

也许你的路线不等待订阅,得到同样的问题几个主题较低 – Sindis 2014-11-20 19:42:04

回答

2

您的模板假定光标正在存储在coutries中。事实并非如此。这将是,如果你的data钩看起来像:

return {countries: Countries.find()}; 

当你的代码编写,光标您的模板上下文所以这应该工作:

{{#each this}} 
    <tr> 
    <td>{{name}}</td> 
    </tr> 
{{/each}}