Domanda

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.

È stato utile?

Soluzione

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'); 
    }
});
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top