2016-06-13 15 views
1

にパラメータを指定して、テキストボックスを移植だから私はそうのように設定流星のルートがあります。流星鉄ルータ

Router.route('/joinRoom/:_id', function() { 
     this.render('joinRoom'); 
}); 

と、単純なHTMLテンプレート:

<template name="joinRoom"> 
    <p>Enter Your Room ID</p> 
    <input placeholder="1" type="text" class="joinID"> 
    <button class="submit" type="submit" value="submit">Join Room -></button> 
</template> 

をそして、私は移入したいです_idパラメータとして渡されたデータは、<input>内のテキストになります。

Iron Routerのドキュメントを見てみましたが、わかりませんでした。これはどうすればいいですか?

答えて

0

あなたのヘルパーでRouter.current().paramsを使用すると、URLからパラメータを取得できます。

<input placeholder="1" type="text" class="joinID" value={getId}> 

ヘルパー:

getId: function() { 
    var params = Router.current().params; 
    return params && params._id ? params._id : ''; 
} 
0

バックエンドからテンプレートにデータを送信する方法は次のとおりです。

this.render('joinRoom', {id :this.params._id}); 

テンプレートでは、次の方法で達成できます。

<input value={{ id }} /> 
関連する問題