Unable to retrieve data from meteor collection -
i'm trying retrieve data meteor collection. while being able insert data, data not getting fetched. i'm using iron router. page appears blank without error or warning message in browser console.
list-article.js
template.articlelist.helpers({ articles: function () { return articles.find(); } // articles: [ // { "articletitle": "title1" }, // { "articletitle": "title2" } // ] });
list-article.html
<template name="articlelist"> {{#each articles}} <li>{{articletitle}}</li> {{/each}} </template>
connecting meteor mongodb using terminal, data exist:
command: db.articles.find();
{ "_id" : "ctck6hkfx3nkotae4", "articletitle" : "sdfsdf" } { "_id" : "jyncggxtsfeq9y9bi", "articletitle" : "sdfsdfsdf" } { "_id" : "dgvjdzu4feqraex7a", "articletitle" : "gfhfgh" } { "_id" : "t9lr3wswrhhlhnpsu", "articletitle" : "sdfsdf", "articleabstract" : "yfdhfgh" } { "_id" : "dnazafutb24qa6jp9", "articletitle" : "fghf", "articleabstract" : "sdf", "articledescription" : "df", "articlereference" : "dfgd", "articlenote" : "dfgrtr", "createdat" : isodate("2015-03-24t17:18:04.731z") }
without autopublish
, data isn't automatically sent on wire despite server , client having collection. have publish data collection on server, , subscribe publication on client. thus,
//server code meteor.publish('allarticles', function() { return articles.find(); });
and:
//client code meteor.subscribe('allarticles');
and you've got data on client. more publications , subscriptions on doc.
Comments
Post a Comment