سؤال

I know something like this can be done but what I'm asking for is an else route that will match any URL (or state) that wasn't previously defined.

This could be handy to catch if a user is trying to access an invalid state or URL.

However, is okey if there is another way to do this :D

Hope this makes sense.

هل كانت مفيدة؟

المحلول

This is taken from the answer to another question, so upvote that one:

App.Router.map(function() {
  this.route('catchAll', { path: '*:' });
});

App.CatchAllRoute = Ember.Route.extend({ 
    redirect: function() {
        this.transitionTo('index'); 
    }
});
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top