2017-02-09 72 views
1

這是我flowrouter的樣子, 我嘗試如下所示的所有三個選項:但無法訂閱Flowrouter訂閱

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'); 
    } 

    } 
}); 

可是,到了最後沒有得到文件..任何建議..在此先感謝

回答

2

我在flowrouter認購的答案是如下:

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

這裏companySettings是出了名在mongodb中收藏