2017-03-21 4 views
0
私IronRouter.jsで

が、私はこのように定義されたホームへのルートを持っているファイル:このルータのルートを変換するには?

Router.route('/', { 
     name: 'home', 
     waitOn: function() { 
     return [ 
      Meteor.subscribe('infosContainers'), 
      Meteor.subscribe('infosMachines'), 
      Meteor.subscribe('alertes'), 
     ]; 
     }, 
     fastRender: true, 
    }); 

その後、私はこの種の定義に変換したいがwaitOnが動作し、エラーを作成されていません。

Router.route('/', function(){ 
    this.layout('layout'); 
    this.render('home'); 
    this.next(); 
    waitOn: function() { 
    return [ 
     Meteor.subscribe('infosContainers'), 
     Meteor.subscribe('infosMachines'), 
     Meteor.subscribe('alertes'), 
    ]; 
    }; 
    fastRender: true; 
}); 

どのようにして2番目の定義に変換できますか?

答えて

1

あなたはこのようにそれを変換し、単に間違っJavaScriptシンタックスで関数宣言、内waitOnプロパティを置く:

Router.route('/', { 
    fastRender: true, 
    subscriptions: function() { 
    return [ 
     Meteor.subscribe('infosContainers'), 
     Meteor.subscribe('infosMachines'), 
     Meteor.subscribe('alertes'), 
    ]; 
    }, 
    action: function() { 
    if (this.ready()) { 
     this.layout('layout'); 
     this.render('home'); 
    } 
    } 
}); 

アイアンルータガイド:http://iron-meteor.github.io/iron-router/

+0

は答えてくれてありがとうしかしAREN購読しますこのように働いて、助けてくれますか? – Jerome

+0

@Jerome私はちょうどコードを変更しました。あなたは 'this.ready()'のチェックを見逃しました。また、 'this.next()'は次の一致するルータ –

+0

@Jeromeこのガイドはhttp://iron-meteor.github.io/iron-router/を開始するための例をたくさん表示する必要があります –

関連する問題