jeudi 23 avril 2015

Conditional redirects in Ember.js

Is there a clean way to redirect only if I'm on the redirecting route and not on their child routes?

App.IndexRoute = Em.Route.extend({
  ...
  redirect: function(record, transition) {
    if(transition.targetName === 'index')
      this.replaceWith('index.nested');

When I remove the if the redirect fires every time I refresh a nested route of index.

The Transition class is private (don't know why I even get it here if it's private) so I shouldn't use it for this kind of stuff.




Aucun commentaire:

Enregistrer un commentaire