2014-03-06 38 views
3

我在Ember应用程序中有一个名为“basic”的路由,对应于API端点的名称。在Ember中是“基本”保留路线名称吗?

此路线不起作用 - 指向它的链接不呈现其模板。

这里有一个JSBin证明了失败:http://emberjs.jsbin.com/hisoxadi/1

JS:

App = Ember.Application.create(); 

App.Router.map(function() { 
    this.route('basic'); 
    this.route('test'); 
}); 

App.IndexRoute = Ember.Route.extend({ 
    model: function() { 
    return ['red', 'yellow', 'blue']; 
    } 
}); 

模板:

<script type="text/x-handlebars"> 
    <h2> Welcome to Ember.js</h2> 

    {{#link-to 'index'}}Index{{/link-to}} 

    {{#link-to 'basic'}}Basic Route{{/link-to}} 

    {{#link-to 'test'}}Test Route{{/link-to}} 

    {{outlet}} 
    </script> 

    <script type="text/x-handlebars" data-template-name="basic"> 
    basic route is here 
    </script> 

    <script type="text/x-handlebars" data-template-name="test"> 
    test route is here 
    </script> 

    <script type="text/x-handlebars" data-template-name="index"> 
    <ul> 
    {{#each item in model}} 
     <li>{{item}}</li> 
    {{/each}} 
    </ul> 
    </script> 
+0

透过Ember的消息来源,我可以看到所有的地方都提到了基本的东西。在讨论路线时,它应该在文档中基本上是保留关键字。 – bcmcfc

+0

太烦人了!好找的人,花了一个小时试图弄清楚这一点。 –

回答

3

为了您的评论扩展位,basic确实是一个保留字。具体而言,这是解析器的保留字。你可以看到源here

useRouterNaming: function(parsedName) { 
    parsedName.name = parsedName.name.replace(/\./g, '_'); 
    if (parsedName.name === 'basic') { 
     parsedName.name = ''; 
    } 
}, 

的,因为有时Ember.js查找路线和控制器在容器中的方式,这是一个公平的打赌说,有没有办法解决这个没有重大代码更改。应该可能会有文件问题提交。

编辑:我创建了这个here的问题。

+0

感谢提交这个问题,我还没有解决它。 – bcmcfc