Charlie
Charlie

Reputation: 10307

EmberJS: splitting the router into multiple files

Can anyone give a good example of how to break the router up into multiple files, and is there any best practise for doing this?

Upvotes: 1

Views: 367

Answers (1)

Bradley Priest
Bradley Priest

Reputation: 7458

Here's a really simplified version of what I'm doing. Just make sure you require the files in the right order.

//router.js
App.Router = Ember.Router.extend({
  accounts: App.AccountsRoutes.extend({
    route: "/account"
  })
  // more routes here
})

//account_routes.js
App.AccountRoutes = Ember.Route.extend({
  index: Ember.Route.extend({
    route: '/',
    connectOutlets: function(router){
       // connect here
    }
  })
  // more routes here
})

Upvotes: 4

Related Questions