Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Meteor 在没有铁路由器的情况下触发全球流星订阅_Meteor_Publish Subscribe_Iron Router_Subscribe - Fatal编程技术网

Meteor 在没有铁路由器的情况下触发全球流星订阅

Meteor 在没有铁路由器的情况下触发全球流星订阅,meteor,publish-subscribe,iron-router,subscribe,Meteor,Publish Subscribe,Iron Router,Subscribe,这应该很容易 以下是我想要的: 第1页:订阅“列表”集合 第2页:显示“列表”集合中的项目用户然后从列表中选择一个项目,返回_id 第3页:使用_id订阅“数据”收集我是如何做到的: 用户登录->呈现用户布局->将currentPage设置为 加载 如果用户已经选择了一个项目,请将currentPage设置为userSplash,否则将currentPage设置为userProjects,用户将在其中选择一个项目,然后转到userSplash Render userSplash->订阅所需的项目

这应该很容易

以下是我想要的:

第1页:订阅“列表”集合

第2页:显示“列表”集合中的项目用户然后从列表中选择一个项目,返回_id

第3页:使用_id订阅“数据”收集我是如何做到的:

用户登录->呈现用户布局->将currentPage设置为 加载 如果用户已经选择了一个项目,请将currentPage设置为userSplash,否则将currentPage设置为userProjects,用户将在其中选择一个项目,然后转到userSplash Render userSplash->订阅所需的项目数据->完成后加载仪表板
答案提供了一些有用的信息

您所说的“不使用熨斗:路由器”是什么意思?我不明白,当它能提供解决方案时,你为什么要放弃它。iron:router会导致我的应用程序的其他部分出现问题。我正在使用Template.dynamic和一个会话变量进行路由。如果Template.dynamic问题是阻止您使用Iron Router解决此问题的唯一问题,我强烈建议将Iron Router与包一起使用。这将允许您正确地使用Iron Router来解决此问题,并能够使用动态模板。谢谢,我现在已经解决了它,但看起来它在未来的项目中会很有用。如果你不介意,请看看我的解决方案,如果有任何缺陷,请告诉我。
Template.userLayout.created = function() {
  Session.set('currentPage', 'loading');
  return Meteor.subscribe('projects', user.profile.company_id, function() {
    if (currentProject_id !== void 0) {
      return Session.set('currentPage', 'userSplash');
    } else {
      return Session.set('currentPage', 'userProjects');
    }
  });
};
Template.userSplash.rendered = function() {
  return Meteor.subscribe('tasks', currentProject_id, function() {
    return Session.set('currentPage', 'userDashboard');
  });
};