Dimuthu Nilanka
Dimuthu Nilanka

Reputation: 420

How does Ember.js nest routes?

Sorry I'm new to ember.js. I really want to do is create a ember.js based app only for admin section. this app should be handle admin section urls only http://mydomain.com/admin/ ( eg: /admin/photos/, /admin/users) others should be work as normal url's. Can I do this with ember.js?

Upvotes: 0

Views: 311

Answers (2)

Glen Selle
Glen Selle

Reputation: 3946

You should use Ember resources to nest routes. So for your example you want to do something like this:

AppName.Router.map(function() {
  this.resource('admin', function() {
    this.route('photos');
    this.route('users');
  });
});

The above will create a /admin/photos and /admin/users route. mokane linked to the the right spot in the Ember docs, but for future-proofing, I'd like to just put the answer in the post so anyone else can see the answer even if the docs location ever changes.

NOTE: I'd like to include an important point made by Ugis Ozols in the comments below which is that in Ember, resources are usually nouns while routes are typically verbs. So you would usually have a resource like /tweet (which is a noun) and then several routes for that resource like create, edit and delete.

Upvotes: 3

intuitivepixel
intuitivepixel

Reputation: 23322

Yes, you can. Check out this section on the ember.js documentation for more info: http://emberjs.com/guides/routing/defining-your-routes/

Upvotes: 1

Related Questions