【发布时间】:2015-12-20 11:11:16
【问题描述】:
我是 Meteor 的新手,我正在尝试使用 angular-meteor 构建在线报告应用程序,但在尝试使用 publish 和 subscribe 时遇到问题。
在 lib/collections.js 中,
TestReport = new Mongo.Collection('test_report');
在 server/publications.js 中,
Meteor.publish('testReportDetail', function(reportID) {
check(reportID, String);
return TestReport.findOne({_id: reportID});
});
在client/test_report_detail.js,
angular.module('myapp').controller('myCtrl', function($scope, $reactive, $stateParams) {
$reactive(this).attach($scope);
this.subscribe('testReportDetail', $stateParams.reportID);
this.helpers({
reportDetail: function() {
return TestReport.find({_id: $stateParams.reportID});
}
});
});
当客户端浏览器尝试访问报告详细信息时,它会在控制台中收到错误
typeError: fn is not a function
任何想法...?
【问题讨论】:
标签: javascript angularjs meteor angular-meteor