简体   繁体   中英

Meteor JS: Dynamic Layout Template

I want to make the layout template dynamic. The value of the layout template would be fetch in the server using a Meteor.call 'getLayoutTemplate'. Where shall I put the Meteor.call? And it should wait until it fetches the value of the Meteor.call. Any ideas?

Router.configure
  layoutTemplate: ????
  notFoundTemplate: 'notFound'

I would put the method call in a onAfterAction hook and then set the layoutTemplate depending on the call's result:

Router.route('/route', {
  name: 'route',
  onAfterAction: function() {
    var routerInstance = this;
    Meteor.call('method', function(error, result) {
      routerInstance.layoutTemplate = result;
    });
  }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM