用户电子邮件未显示在模板[METEOR]中!

zen*_*126 4 meteor meteor-accounts

我有一个用户索引,并希望显示每个用户的信息.用户ID显示正常,但应用程序未显示电子邮件.

这是我的模板:

<template name="users">
  <h1>List of all users</h1>
  {{#each users}}
    <div class="list_item">
      <p>ID: {{_id}}</p>
      <p>Email: {{email}}</p>
    </div>
  {{/each}}
</template>
Run Code Online (Sandbox Code Playgroud)

以下是我的路线:

Router.route('/users', function () {
  this.render('users');
}, {
  waitOn: function() {
    return [
      Meteor.subscribe('users')
    ]
  },

  data:  {users: Meteor.users.find({})}
});
Run Code Online (Sandbox Code Playgroud)

最后,我的出版物:

Meteor.publish('users', function () {
  return Meteor.users.find({}, {fields: {emails: 1, profile: 1}});
});
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

sai*_*unt 5

显示电子邮件的正确方法是:

<p>Email: {{emails.[0].address}}</p>
Run Code Online (Sandbox Code Playgroud)

电子邮件地址作为数组存储在用户对象中.

您可以通过Meteor.user()在控制台中输入来检查:

Object {
  ...
  emails: Array[1]
    0: Object{
      address: "username@domain.com",
      verified: false
    }
  ...
}
Run Code Online (Sandbox Code Playgroud)