集合在'meteorJs'中不返回值?
我需要帮助,在meteorJs集合中不返回值。下面是我的代码,我犯了一个错误,请验证并建议我集合在'meteorJs'中不返回值?,meteor,Meteor,我需要帮助,在meteorJs集合中不返回值。下面是我的代码,我犯了一个错误,请验证并建议我 Collection name: hcare_users = new Meteor.Collection("hcare_users"); Html Code: <template name="client"> <tbody> {{#each clientList}} <tr> <
Collection name:
hcare_users = new Meteor.Collection("hcare_users");
Html Code:
<template name="client">
<tbody>
{{#each clientList}}
<tr>
<td><div>{{userid}}</div></td>
<td><div>{{firstname}}</div></td>
<td><div>{{lastname}}</div></td>
<td><div style="float:left;">{{bday}}/</div><div style="float:left;">{{bmonth}}/</div><div style="float:left;">{{byear}}</div></td>
<td>
<div>{{address}}</div></br>
<div>{{city}}</div></br>
<div>{{state}}</div></br>
<div>{{country}}</div></br>
<div>{{phoneno}}</div></br>
<div>{{zipcode}}</div></br>
</td>
<td><div>{{ssn}}</div></td>
<td><div>{{permissions}}</div></td>
</tr>
{{/each}}
</tbody>
</template>
JS Code:
Template.client.clientList = function ()
{
return hcare_users.find();
};
集合名称:
hcare_用户=新Meteor.Collection(“hcare_用户”);
Html代码:
{{{#每个客户列表}
{{userid}}
{{firstname}}
{{lastname}}
{{bday}/{bmmonth}/{{byear}
{{地址}
{{城市}
{{state}}
{{国家}
{{phoneno}
{{zipcode}}
{{ssn}}
{{权限}
{{/每个}}
JS代码:
Template.client.clientList=函数()
{
返回hcare_用户。find();
};
为meteor应用程序添加自动发布软件包它返回收藏值,您可以在其中显示收藏详细信息。以下是如何在没有自动发布软件包的情况下发布和订阅收藏(强烈推荐,因为它具有安全性和性能优势)
服务器发布
if (Meteor.isServer) {
// publish entire hcare_users collection
Meteor.publish('hcareUsers', function() {
return hcare_users.find({});
});
}
if (Meteor.isClient) {
//subscribe to the published collection
Meteor.subscribe('hcareUsers');
}
客户端订阅
if (Meteor.isServer) {
// publish entire hcare_users collection
Meteor.publish('hcareUsers', function() {
return hcare_users.find({});
});
}
if (Meteor.isClient) {
//subscribe to the published collection
Meteor.subscribe('hcareUsers');
}
html代码位于名为
client
的模板中?我看不出这有什么问题。你验证过集合不是空的吗?我正在mongoDb中检查值在hcare_用户中,但它返回以显示上面提到的值。上述代码不起作用。@Christian FritzDo你有发布/订阅频道,还是自动发布软件包?我没有使用autopublish package@Hubert OG