Routes.js:
Router.configure({
layoutTemplate: "defaultLayout",
before: function () {
if(!Meteor.user()) {
this.layout("loginLayout");
this.render('login');
}else{
this.layout("defaultLayout");
this.next();
}
}
});
Router.route('/',function(){
this.render('login');
this.layout('loginLayout');
});
Router.route('/botlist',{
template: "projects",
name: "projects",
data: function(){
return Projects.find({});
},
waitOn: function(){
return Meteor.subscribe('projects',Session.get("username"));
}
});
我有一个js看起来像的登录页面:
....
'click #btn-login'(e, t) {
var username = $('#email').val(),password = $('#password').val();
Meteor.call('loginWithad',username,password,function(err,response){
if(response.err){
.. }
else{
Meteor.call('finishLogin',username,password,function(err,res){
if(err){
...
}
else{
Session.set("username",res.givenName);
Router.go("/botlist"); //--> this router.go doesn't route to /botlist template
}
})
....
我的路由器定义有什么问题吗?我尝试了多种解决方案:
this.redirect()
Router.push
this.stop()
然后Router.go()
答案 0 :(得分:0)
您需要提供路线名称作为参数。所以:
变化
Router.go("/botlist");
到
Router.go("projects");