Ember.Router.extend({
root: Ember.State.extend({
posts: Ember.State.extend({
route: '/posts',
index: Ember.State.extend({
route: '/',
showPost: Ember.State.transitionTo('show'),
connectOutlets: function(router, post) {
router.get('applicationController')
.connectOutlet(App.PostsView, App.Post.all());
}
}),
show: Ember.State.extend({
route: '/:post_id',
connectOutlets: function(router, post) {
router.get('applicationController')
.connectOutlet(App.PostView, post);
}
})
})
})
});
ROUTER.
1. User clicks link
2. Transition to show state, passing current post
3. Serialize the post via .get('id'), set URL /posts/51
4. Call connectOutlets with the post
5. Replace the main outlet with the PostView, with its
controller set to PostController with content of post