This seems to suggest that the answer is yes:
... but I just want to confirm.
In my case, as a learning exercise, I'm building a calendar in Ember, with monthly displays. I need to be able to link from a given month to the previous month, and to the next month.
So I'd like to be able to
{{ linkTo calendar_month year month }}
and
this.transitionTo('calendarMonth', year, month)
Wondering if this is feasible without using nested resources. I can get it working with something like:
App.Router.map(function() {
this.resource("year", { path: "calendar/:year" }, function() {
this.resource("calendar_month", { path: "/:month" }, function() {
this.route('index');
});
});
});
... but this involves introducing a Year object which might not really need to exist from a modeling perspective, just so I can use its id in linkTo
I'd prefer to set up a route with two parameters/dynamic segments:
App.Router.map(function() {
this.route('calendar_month', { path: 'calendar/:year/:month'});
});
But am I correct that this is not possible? I just want to make sure I'm doing this the cleanest, emberiest way possible.
Put another way:
I understand this notion that "If your user interface is nested, then your routes should be nested", but, if my url is nested, this does not necessarily imply that my interface will be nested as well. So I'm wondering: if my url is nested, is it always best practice to build corresponding nested models?
Any guidance / clarification much appreciated.
thanks,
serialize()
andmodel()
methods live insidecalendar_month.js
in this example? – Bookstand