I'm trying for my application to automatically redirect to a route /myroute/
when the application loads.
What I did is add the following to my app/router/application.js
app/routes/application.js
import Ember from 'ember';
export default Ember.Route.extend({
redirect: function() {
this.transitionTo('myroute');
}
});
This works however the problem is my URLs not longer work.
When I go to http://host/#/myroute2
it still goes to myroute
What is the correct way of doing this?
Create an index route in your routes folder, app/routes/index.js
, this will serve as the application.index
route and will only redirect when you are in it i.e in the base url.
The code you are using is correct just misplaced since you are always in application route.
If you are using the ember inspector ( a great tool I might add ) you can see it in action:
As you can see from the picture my current route passes through the application route even though I am on the work resource. I hope this made sense, if you need any more help let me know in the comments.