2014-11-20 130 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}}