【问题标题】:Flowrouter SubscriptionsFlowrouter 订阅
【发布时间】:2017-02-09 07:06:44
【问题描述】:

这就是我的流量路由器的样子, 我尝试了下面显示的所有三个选项:但无法订阅

import {CompanySettings} from '../imports/api/companysettingsMaster.js';
// And imported the api also..
FlowRouter.route('/', {
  name: 'home',
  subscriptions: function() {
    // 1.
    return this.register('companySettings', Meteor.subscribe('companySettings'));
    // 2.
    this.register('CompanySettings', Meteor.subscribe('companySettings'));
    // 3.
    return Meteor.subscribe('companySettings');
  },
  action: function() {

    var themeSettings = CompanySettings.findOne({
      "companyId": 101
    });
    if (themeSettings) {
      console.log(themeSettings);
      var scaleProcess = themeSettings.generalSettings.scaleProcess;

      if (scaleProcess == 'retail')
        BlazeLayout.render("retailMainLayout", {
          content: "homepages"
        });
      else {
        BlazeLayout.render("WSEmainLayout", {
          content: "homepages"
        });
      }
    } else {
      console.log('no themeSettings');
    }

  }
});

但是,最后没有得到文件..任何建议..提前谢谢

【问题讨论】:

    标签: meteor publish-subscribe flow-router


    【解决方案1】:

    我在flowrouter中得到了订阅的答案,如下:

    FlowRouter.route('/', {
        waitOn: function () {
           return Meteor.subscribe('companySettings');
        },    
    });
    

    这里 companySettings 是 mongodb 中的集合名称

    【讨论】:

      猜你喜欢
      • 2016-05-26
      • 2017-06-20
      • 1970-01-01
      • 1970-01-01
      • 2020-10-17
      • 1970-01-01
      • 2019-12-29
      • 2019-01-03
      • 2020-03-29
      相关资源
      最近更新 更多