在没有#something的情况下为index.html创建默认状态

时间:2012-08-01 21:51:57

标签: javascript ember.js ember-old-router

我有这个Ember路由器:

App.Router = Em.Router.extend({
    enableLogging: true,
    location: 'hash',    
    root: Em.Route.extend({
        // EVENTS
        gotoList: Ember.Route.transitionTo('list'),

        // STATES
        list: Em.Route.extend({
            route: '/list',
            connectOutlets: function(router, context) {
                router.get('applicationController').connectOutlet('list');
            }
        })
    })
});

我希望路由'/'将显示列表插座(与'/list'相同),但我不想复制像列表一样的状态。我能以某种方式告诉默认状态列表的根吗?

1 个答案:

答案 0 :(得分:2)

也许您正在寻找redirectsTo('list')

App.Router = Em.Router.extend({
  enableLogging: true,
  location: 'hash',    
  root: Em.Route.extend({
    // EVENTS

    gotoList: Ember.Route.transitionTo('list'),

    // STATES
    index: Em.Route.extend({
      route: '/',
      redirectsTo: 'list'
    }),

    list: Em.Route.extend({
        route: '/list',
        connectOutlets: function(router, context) {
            router.get('applicationController').connectOutlet('list');
        }
    })
  })
});