【发布时间】:2015-06-26 04:45:21
【问题描述】:
Router.route('/courses/:_catalog', function () {
var courseCatalog = this.params._catalog.toUpperCase();
Meteor.subscribe("courseCatalog", courseCatalog);
this.render('CourseDetail', {
to: 'content',
data: function () {
return Courses.findOne({catalog: courseCatalog});
}
});
}, {
onAfterAction: function() {
if (!Meteor.isClient) {
return;
}
debugger
var course = this.data(); <======
SEO.set({
title: "course.catalog"
});
}
});
在上面的代码中,请看debugger语句。我想访问数据,但似乎我做错了,因为this.data 不存在。我也尝试了Courses.find().fetch(),但我在onAfterAction 中只得到了一个空数组。什么是正确的语法,我错过了什么?
【问题讨论】:
标签: meteor iron-router