2016-05-18 2 views
0

私はブログ投稿を含むコレクションを持っており、それらをページに表示しようとしています。以下のコードは、すべてのブログ投稿を一覧表示していないので、わからないのです。私が言うことができる限り、出版しています。#各ブログ投稿が表示されない

パス:blog.html

{{#each Blog}} 
    <p>{{details}}</p> 
{{/each}} 

パス:blog.js

Template.blog.onCreated(function() { 
    var self = this; 
    self.autorun(function(){ 
     var id = FlowRouter.getParam('id'); 
     self.subscribe('blog', id); 
    }); 
}); 

パス:Blog mongoDB example

{ 
    "_id": "JvLqxFisXc3PLeqSh", 
    "details": "Test three", 
} 

パス:publish.js

Meteor.publish('blog', function (id) { 
    check(id, String); 

    return Blog.find({}); 

}); 

答えて

0

私はヘルパーを追加する必要があります。

Template.blog.helpers({ 
    blogPost:()=> { 
     return Blog.find({}); 
    } 
)} 

パス:blog.html

{{#each blogPost}} 
    <p>{{details}}</p> 
{{/each}} 
関連する問題