0

I'm new in meteor templates and trying to render emails from the next user objects with emails array:

{
  "_id" : "8ngggLthJ6NRKJRfG",
  "emails" : [
    {
        "address" : "[email protected]",
        "verified" : false
    }
  ]
}

Template helper:

Template.user.helpers({
  users() {
    return Meteor.users.find({}, { sort: { createdAt: -1 } }).fetch();
  },
});

Template:

<template name="chats">
  <ul>
   {{#each users}}
     {{> user}}
   {{/each}}
 </ul>
</template>


<template name="user">
  <li>{{emails[0].address}}</li>
</template>

but I get error: "Error: Can't call non-function: [object Object]"

How can I fix it? Thanks in advance.

2
  • 1
    I think the correct syntax is emails.[0].address with an extra dot, can you try that? Commented Aug 10, 2017 at 13:29
  • Yes, it help me! Thanks! Commented Aug 10, 2017 at 15:35

1 Answer 1

1

emails is an array, so kindly use emails.[0].address

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.