2015-09-18 223 views
0

铁路路由器找不到我确定的路径正确定义。路径名显示为有效并存在于流星壳中,但在我的Chrome控制台中返回为“未定义”。这里的模板声明:pathFor无法找到路由 - 铁路由器和流星

<template name="vidPreview"> 
<div class="videoPreview"> 
    <h2>{{title}}</h2> 
    <a href="{{pathFor route='singleVideo' _id=this._id }}">Play</a> 
    <p>Created At: {{createdAt}}</p> 
    {{#if isLive}} 
     <p>LIVE</p> 
    {{/if}} 
    <p>Viewers: {{uniqueViewers}}</p> 
    <p>Views: {{views}}</p> 
    <p>Location: {{location}}</p> 
    <ul> 
     {{#each genres}} 
      <li><p>{{this}}</p></li> 
     {{/each}} 
    </ul> 
    <p>Created by: {{creator}}</p> 
</div> 
</template> 

而这里的路线声明:

Router.route('/video/:_id',{ 
    name: 'singleVideo', 
    template: 'singleVideo', 
    layoutTemplate: 'singleVideo', 
    data: function(){ 
    var currentVideo = this.params._id; 
    return Videos.findOne({ _id: currentVideo }); 
    }, 
    action: function(){ 
    this.render('singleVideo'); 
    } 
}); 

没有帮手的vidPreview模板操作。数据上下文是单个Video对象的数据上下文,并且该模板被多次放入父模板中。非常感谢帮助。

+0

你在哪里定义路由?你确定它在客户端可用吗? – val

回答

0

我想在pathFor路线名称参数是位置,即

{{pathFor 'singleVideo' _id=this._id }}