2013-01-19 107 views
4

我目前正在將我的應用程序從ember 1.0.0-pre2遷移到1.0.0-pre4,我遇到了新的路由API問題。Ember.js新路由api

我的用例似乎沒有被文檔中的新指南覆蓋。

我一直在旁邊的應用程序的其餘部分側聊天格,我的應用程序模板看起來是這樣的:

<script type="text/x-handlebars" data-template-name="application"> 
    <div id="main-content"> 
     <aside> 
      {{outlet chat}} 
     </aside> 
     {{outlet main}} 
    </div> 
</script> 

隨着舊的路由器的conf映射在兩個控制器及其各自的URL網點。

Router : Ember.Router.extend({ 
    root: Ember.Route.extend({ 
     index: Ember.Route.extend({ 
      route: '/', 
      connectOutlets: function(router, event) { 
       router.get('applicationController').connectOutlet('main', 'main'); 
       router.get('applicationController').connectOutlet('chat', 'chat'); 

      } 
     }) 
    }) 

我怎樣才能遷移此代碼到新的API或更改我已經編寫這一點,如果這是一個不好的設計爲灰燼的方式。

我想我可以將我的問題推廣到我們如何使用新的路由API將幾個控制器(處理頁面的不同部分)映射到相同的URL。

THX

回答

2

根據文檔遵循的示例[1]。

App.Router.map(function() { 
    this.resource('index', {path: '/'}); 
}); 

App.IndexRoute = Ember.Route.extend({ 
    renderTemplate: function(controller, model) { 
     this.render('main', {outlet: 'main'}); 
     this.render('chat', {outlet: 'chat'}); 
    } 
}); 

[1] - http://emberjs.com/guides/routing/