In my ember application (version 1.0.0 version) I have a URL structure as follows:
/item /item/{specific-item-name-defined-in-routes}
The router mapping looks something like this:
App.Router.map(function () { this.resource("item", function () { this.resource("my-first-item"); this.resource("another-item"); ... }); });
If the user goes to /item
, I want to display a specific entry (for example, /item/my-first-item
). I can do this using the route redirect
method:
App.ItemRoute = Ember.Route.extend({ redirect: function () { this.transitionTo('my-first-item'); } });
Unfortunately, with this approach, if I manually enter the address bar URL /item/another-item
or go directly to /item/another-item
, the application will redirect me to /item/my-first-item
. If I just switch between nested routes (i.e. by clicking the link in the application, it loads correctly).
How can I redirect redirection only when the nested route was not provided?
source share