【发布时间】:2015-07-08 10:42:52
【问题描述】:
我将要讨论的所有内容的最终结果是子标题没有像我想要的那样在屏幕上呈现。
目前有一个带有 category 字段和 texth 字段的 mongo 集合子标题。
Subheader = new Mongo.Collection('subheader');
Meteor.methods({
subheaderInsert: function(subheaderIdAttributes) {
check(String);
check(subheaderIdAttributes, {
texth: String,
category: String
});
var subheaderId = _.extend(postAttributes, {
submitted: new Date()
});
var subheaderId = SubheaderId.insert(subheader);
return {
_id: subheaderId
};
}
});
有一个路由订阅了副标题和其他页面数据。
Router.route('/', {
name: 'home',
controller: MissionstatementpostController,
waitOn:function () {
return Meteor.subscribe('subheader', 'home');
}
});
发布功能似乎工作正常。
Meteor.publish('subheader', function(cat) {
return Subheader.find({category: cat});
});
来自 mongodb 集合的正确文档正在到达客户端。这可以通过
看到Subheader.findOne(); output Object {_id: "NPo5cwqgjYY6i9rtx", texth: "ex text", category: "home"}
问题从这里开始
本例中控制器加载的模板MissionstatementpostController为postlist
<template name="postsList">
<div class="posts page">
{{> subheader}}
<div class="wrapper">
{{#each posts}}
{{> postItem}}
{{/each}}
</div>
{{#if nextPath}}
<a class="load-more" href="{{nextPath}}">Load more</a>
{{else}}
{{#unless ready}}
{{> spinner}}
{{/unless}}
{{/if}}
</div>
</template>
这是副标题模板
<template name="subheader">
<div class="container">
<p>{{{texth}}}</p>
</div>
</template>
那我搞砸了什么?
谢谢
【问题讨论】:
标签: javascript mongodb meteor routes meteor-blaze