I am trying to learn a meteor, and I am facing several obstacles. I have several nested templates for displaying all user information in my application:
users_list.html:
<template name='usersList'> <div class='users'> {{#each user}} {{> userItem}} {{/each}} </div> </template>
and user_item.html:
<template name='userItem'> <div class='user'> <div class='user-content'> <h3>User:</h3> <h4>Email: {{emails}}</h4> <h5>ID: {{_id}}</h5> ... </div> </div> </template>
and its associated template helper:
Template.usersList.helpers({ user: function(){ return Meteor.users.find().fetch(); } });
This works for top-level properties, but if I try to explicitly access the .address property at index 0 in the email array by changing the above line in user_item.html:
<h4>Email: {{emails[0].address}}</h4>
Meteor complains:
Exception in a task with a queue: Error: it is impossible to call a non-function: [object Object] ...
This bothers me because I can do it in the console:
var userz = Meteor.users.find().fetch(); userz[0].emails[0].address
Any ideas on why Meteor doesn't like this?
In addition, I thought that I might need to save the contents of the email array in a variable and repeat the same template above, except that the emails_list and email_item templates are embedded in the user_item template. It seems viable but too complicated for this use case.
Ultimately, I'm just trying to learn and implement a reasonable template for accessing and displaying the attached attributes of documents in collections. Any thoughts or recommendations would be greatly appreciated.
Chris source share