I would like to have routing hierarchy.
So it would be nice if URLs “#/user/123” and “#/user/123/albums” will work.
And i want to do that this way:
App.Router = Em.Router.extend({
root: Em.Route.extend({
index: Em.Route.extend({
route: '/'
}),
user: Em.Route.extend({
route: '/user/:login',
connectOutlets: function(router, context){
router.get('applicationController').connectOutlet('user', context);
},
albums: Em.Route.extend({
route: '/albums',
connectOutlets: function(router){
router.get('applicationController').connectOutlet('albums');
}
})
})
})
});
Not this way:
App.Router = Em.Router.extend({
root: Em.Route.extend({
index: Em.Route.extend({
route: '/'
}),
user: Em.Route.extend({
route: '/user/:login',
connectOutlets: function(router, context){
router.get('applicationController').connectOutlet('user', context);
}
}),
albums: Em.Route.extend({
route: '/user/:login/albums',
connectOutlets: function(router){
router.get('applicationController').connectOutlet('albums');
}
})
})
});
My first code examle sims to be silly, but i want to have routing hierarchy. Is there any ability to do that?!
This kind of thing is certainly doable. There are many examples out there of nested routes. I can’t check your specific Router against an a real app, but there’s an example very much long this lines in the Ember Application Structure guide. See the section on Nesting. You’ll find this: