Sam
Sam

Reputation: 4339

Ember route method when landing only on route view

When a user lands on my /settings page, I want to redirect them to /settings/overview. How can I accomplish this only when they land on /settings, but not fire when they land on, for example, /settings/account?

Upvotes: 1

Views: 45

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

Create a SettingsIndexRoute and redirect when they hit that route. The index route will only be hit when you hit the root of the resource.

App.SettingsIndexRoute = Em.Route.extend({
  redirect: function(){
    // I'm assuming overview is a route under settings
    // and not a resource under it
    this.transitionTo('settings.overview'); 
  }
});

Upvotes: 1

Related Questions