2012-08-14 84 views
1

我試圖建立在我的餘燼應用的東西,如下面的路由:當灰燼的路由1.0.0預

app= Ember.Application.create({ 
     ApplicationController: Ember.ObjectController.extend(), 
     ApplicationView: Ember.View.extend(), 

     Router: Ember.Router.extend({ 
      root: Ember.Route.extend({ 
       route: '/', 

       aRoute: Ember.Route.extend({ 
        route: '/routeA' 
       }), 
       bRoute: Ember.Route.extend({ 
        route: '/routeB' 
       }) 
      }) 
     }) 
}); 

app.initialize(); 

但打開下面的錯誤頁面時precents它的自我:

Uncaught Error: assertion failed: Could not find state for path 

當挖掘一點點到源代碼的燼,我的位置「哈希」屬性從來沒有設置 - 應設置何時由瀏覽器觸發某種類型的哈希事件。

我在正確的軌道上,我該如何解決這個問題?

回答

3

只有葉子路由可路由,當輸入'/'時,路由器不知道他必須去的地方。 我建議你定義一個只重定向到葉子路徑的索引路由。 例如:

Router: Ember.Router.extend({ 
     root: Ember.Route.extend({ 
      index: Ember.Route.extend({ 
       route: '/', 
       redirectsTo: 'aRoute' 
      }), 

      aRoute: Ember.Route.extend({ 
       route: '/routeA' 
      }), 
      bRoute: Ember.Route.extend({ 
       route: '/routeB' 
      }) 
     }) 
    }) 
+1

我想'redirectsTo'預計路由的名稱,即「aRoute」 – zentralmaschine 2012-08-14 12:25:27

+0

是的,謝謝你@NielsHoffmann – 2012-08-14 13:17:57

+0

真當然也可以不感謝的:) – eble 2012-08-14 13:45:27