2014-03-06 39 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