我有这个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'
相同),但我不想复制像列表一样的状态。我能以某种方式告诉默认状态列表的根吗?
答案 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');
}
})
})
});