Okay, I’m faced with a situation where I need to use specific names for the url’s dynamic segments.
This requirement was not present when the project started and I have written plenty of code already relying on the ember’s conventions. Also, I have places in the app where the {{#link-to}} and transitiontTo aren’t used because the user comes in to my app from an external site and they click on a hard-wired url. My question is simply this:
Is there a way to ‘alias’ a route so, two matching routes take you to the same place? for example, if I have a route defined like this:
this.route(‘foo’, {path: ‘/foo’}), I want to be able to specify declaratively,
this.route.alias(‘foo’, ‘bar’) and now, if the url is /#/bar,
all the FooControllers and FooRoutes work correctly without any change? Is this possible?
serialize doesn’t work for me because the issue I’m facing is not to convert a route’s model into parameters, rather, I want ember to recognize that the same model, controller and view will need to be triggered for all the routes that I specify. That is the same as saying, I would like the path parameter which I use while declaring routes to be an array of hashes that looks something like this:
this.route('foo', paths: [{path: '/foo'}, {path: '/bar'}]) and have ember realize that both http://blah/#/bar and http://blah/#foo/ should cause the route transition into the foo route and cause the appropriate FooController and FooViews to be active.
You wouldn’t really be following Ember conventions if you specify the same controller & views for different routes. However Ember will let you override the generated defaults for the controller & view.
Ember’s Route has a controllerName and viewName property that you can set in the routes.
I think you will still need a seperate route for each unique path, unless you want to use a glob url.