Skip to content

Instantly share code, notes, and snippets.

@boy-jer
Last active December 11, 2015 11:28
Show Gist options
  • Save boy-jer/4593437 to your computer and use it in GitHub Desktop.
Save boy-jer/4593437 to your computer and use it in GitHub Desktop.
emberjs router V3
Adapted from Tchak's code here https://gist.github.com/4511824
//Passing a function instead of route name will setup an anonymous route and assign the function as `redirect` hook.
//Passing object instead of route name can be used to redirect for example.
App.Router.map(function {
this.resource('index', { path: '/'}, function() {
if (this.controllerFor('login').get('isSignedIn')) {
this.transitionTo('search');
} else {
this.transitionTo('signIn');
}
});
this.route('search');
this.route('cart');
this.route('tickets');
this.resource('preferences', function() {
this.route('index', {path: '/'}, {redirectTo: 'email'});
this.route('email', {path: /'email'});
});
this.route('signIn');
});
renderTemplate: () ->
@render('index')
@render('social', {outlet: 'social'})
@render('earnings', {outlet: 'earnings'})
@render('usage', {outlet: 'usage'})
connectOutlets: (router) ->
router.get('applicationController').connectOutlet('index')
router.get('indexController').connectOutlet('social', 'social')
router.get('indexController').connectOutlet('earnings', 'earnings')
router.get('indexController').connectOutlet('usage', 'usage')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment