Reputation: 61
I wanna create a transition, like, if someone goes to index or to /profile-details it will be redirected to /profile-details/preview. Here is my map and redirection code:
UserProfileApp.Router.map(function () {
this.resource('profile', { path: '/' }, function () {
this.resource("personal", { path: "personal-details" }, function () {
this.route("preview", { path: "preview" });
this.route("edit", { path: "edit" });
});
this.route("loyalty", { path: "loyalty-membership" });
this.resource("passengers", { path: "passengers" }, function () {
this.route("new", { path: "new" });
this.route("passenger", { path: ":passenger_id" });
});
this.route("password", { path: "password" });
});
});
UserProfileApp.ProfileRoute = Ember.Route.extend({
beforeModel: function () {
this.transitionTo('personal');
}
});
UserProfileApp.PersonalRoute = Ember.Route.extend({
beforeModel: function () {
this.transitionTo('personal.preview');
}
});
If I remove any of the transitionTo, it works accordingly, but with both the transitionTo's in is not working
Upvotes: 0
Views: 1062
Reputation: 138
In addendum to @Edu: You can also pass in an id which you want to transite to:
this.transitionTo('personal', eventualId);
Upvotes: 1
Reputation: 2520
Have you tried this?
UserProfileApp.ProfileRoute = Ember.Route.extend({
beforeModel: function () {
this.transitionTo('personal');
}
});
UserProfileApp.PersonalRoute = Ember.Route.extend({
beforeModel: function () {
this.transitionTo('preview');
}
});
Good luck
Upvotes: 0