meteor collection无法从服务器获取到客户端
我一直在读流星文件,但目前我面临以下问题 代码块1 我可以使用Meteor.quizzes.find从模板中查看上述集合 代码块2 服务器端代码为 路线代码如下 但当我尝试访问Meteor.movies.find时,什么都没有出现,我想订阅方法也不会返回任何内容meteor collection无法从服务器获取到客户端,meteor,meteorite,Meteor,Meteorite,我一直在读流星文件,但目前我面临以下问题 代码块1 我可以使用Meteor.quizzes.find从模板中查看上述集合 代码块2 服务器端代码为 路线代码如下 但当我尝试访问Meteor.movies.find时,什么都没有出现,我想订阅方法也不会返回任何内容 我花了很多时间来修复,但找不到解决方案。请在这方面帮助我。您需要使用Iron Router的waitOn或subscriptions选项订阅您的电影出版物,或者自己拨打订阅电话。请注意,在测验代码中,在运行路由之前,您正在等待测验订阅
我花了很多时间来修复,但找不到解决方案。请在这方面帮助我。您需要使用Iron Router的waitOn或subscriptions选项订阅您的电影出版物,或者自己拨打订阅电话。请注意,在测验代码中,在运行路由之前,您正在等待测验订阅 手动调用订阅: //客户 流星。订阅“电影”功能{ console.logMovies.find.count;//3 }; 使用Iron Router处理您的订阅: //客户 路由器。路由“/电影”{ waitOn:函数{return Meteor.subscribe'movies';} };
顺便说一下,您使用的是旧的、传统的Iron路由器API。我建议您看看。谢谢您的回复。当我使用Meteor.subscribe'users时,它可以工作,但当我使用Meteor.subscribe'movies时,它不能工作。如果我需要添加任何其他代码,如配置或其他东西,请您帮助我。我已经使用iron router标签编辑了实际问题帖子:v0.7.1我使用accounts ui bootstrap下拉列表和所有用户和通知,我可以从客户端访问所有用户和通知。目前,我正在使用创建全新的集合,即电影,我无法从客户端访问。请在这方面帮助我嘿,我已经通过编写Meteor解决了这个问题。直接在客户端订阅'movies'方法,而不是在Meteor中写入。订阅'movies',函数{console.logMovies.find.count;//3我刚刚连接了Meteor。订阅文件夹/client/movies.js中的'movies',效果很好,但我不知道为什么它会起作用。为什么不使用路由。如果可能,你能帮我理解};
Router.map(function() {
this.route('quizzes', {
path: '/quizzes',
waitOn: function() {
return Meteor.subscribe('quizzes');
}
});
})
// Declare server Movies collection
Movies = new Meteor.Collection("movies");
// Seed the movie database with a few movies
Meteor.startup(function () {
if (Movies.find().count() == 0) {
Movies.insert({ title: "Star Wars", director: "Lucas" });
Movies.insert({ title: "Memento", director: "Nolan" });
Movies.insert({ title: "King Kong", director: "Jackson" });
}
console.log(Meteor.movies.find().count()) //retunr 3 records
Meteor.publish('movies', function(){
return Movies.find({});
})
Router.map(function() {
//Admin routes
this.route('userManagement', {
path: '/user-management',
waitOn: function() {
return Meteor.subscribe('users');
}
});
});
when I use the users in the above block of code, It working fine.
but when i use movies/quizzes on same route map .
Router.map(function() {
//Admin routes
this.route('moviesManagement', {
path: '/movies-management',
waitOn: function() {
return Meteor.subscribe('movies');
}
});
});