I understand that routes are used to map URLs to templates, but apparently you could either define routes with this.route or this.resource
App.Router.map(function() {
this.route("about", { path: "/about" });
this.route("favorites", { path: "/favs" });
});
App.Router.map(function() {
this.resource('posts', { path: '/posts' }, function() {
this.route('new');
});
});
Do you just use this.resource if you want to define subroutes to a route or is there another rationale I'm not getting?
I understand that routes are used to map URLs to templates, but apparently you could either define routes with this.route or this.resource
App.Router.map(function() {
this.route("about", { path: "/about" });
this.route("favorites", { path: "/favs" });
});
App.Router.map(function() {
this.resource('posts', { path: '/posts' }, function() {
this.route('new');
});
});
Do you just use this.resource if you want to define subroutes to a route or is there another rationale I'm not getting?
Share Improve this question edited Apr 2, 2013 at 1:46 Marco Petersen asked Apr 2, 2013 at 1:23 Marco PetersenMarco Petersen 3313 silver badges14 bronze badges2 Answers
Reset to default 8Do you just use this.resource if you want to define subroutes to a route or is there another rationale I'm not getting?
That's the basic idea.
- resource = parent (usually a noun)
- route = child (often a verb)
Also keep in mind that the router always points to a current route. It cannot transition to a resource. Behind the scenes ember automatically generates an 'index' route underneath every resource, so even if you define something like this:
App.Router.map(function() {
this.resource("about", { path: "/about" });
});
you end up with this:
App.Router.map(function() {
this.resource('about', { path: '/about' }, function() {
this.route('index');
});
});
this is being depreciated in ember 3.x. there is no more this.resource()