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?
Do 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.
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');
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With