LoginSignup
1
1

More than 5 years have passed since last update.

Ember.Routerは入れ子構造にできる

Last updated at Posted at 2012-12-13

Router定義を入れ子構造にして、サブディレクトリに当たるURLにひもづけることができます。

App.Router = Ember.Router.extend({
  root: Ember.Route.extend({
    index: Ember.Route.extend({
      route: '/',
      redirectsTo: 'calendar.index'
    }),

    calendar: Ember.Route.extend({
      route: '/calendar',

      index: Ember.Route.extend({
        route: '/'
      }), 

      preferences: Ember.Route.extend({
        route: '/preferences'
      })
    }),

    mail: Ember.Route.extend({
      route: '/mail',

      index: Ember.Route.extend({
        route: '/'
      }),

      preferences: Ember.Route.extend({
        route: '/preferences'
      })
    })
  }) 
});

App.initialize();

var router = App.get('router');

router.transitionTo('calendar.preferences');

// URL => www.myapp.com/calendar/preferences

router.transitionTo('mail.preferences');

// URL => www.myapp.com/mail/preferences

router.transitionTo('index');

// URL => www.myapp.com/mail

このページのコードを参考にしました。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1