Reputation: 229
My html code:
<template name="homeItem">
<li class= "{{selectedClass}}">{{{content}}}</li>
<li class= "tagsBody">{{#each tags}}<a href="/tagsTemp/{{this}}">{{tags}}</a> {{/each}}</li>
</template>
The subscribing to "contents" is being done at the route controller level.
Now the "tags" is an array which is a part of "content" which is a document in a collection named "contentsList".
I have used a homeitem helper function which goes such as this:
JS client code
Template.homeItem.helpers({
'tags':function(){
return contentsList.findOne({_id: this._id}).tags
}
});
The errors that are returned are:
1) Exception in template helper: TypeError: Cannot read property 'tags' of undefined.
2)Uncaught Error: {{#each}} currently only accepts arrays, cursors or falsey values.
3)Exception from Tracker recompute function:TypeError: Cannot read property '0' of null
How can I solve this problem? I am new to programming. So, please forgive me for diverting from any programming conventions. Any help would be hugely appreciated.
Upvotes: 2
Views: 74
Reputation: 2010
contentList.findOne({_id: this._id})
is returning null, so when you try to do null.tags
it shows up as undefined.
Make sure that a subscription exists for contentsList and that you can search it. Test this by running contentList.find().fetch()
to see what comes back. If nothing comes back, your subscription doesn't exist.
Upvotes: 0