Reputation: 13379
I want to handle routes which are not available by displaying something like 404 not found page. How can i do that?
for example, http://jsbin.com/oZUHiXe/1/edit in this index is available so this(http://jsbin.com/oZUHiXe/1#index) doesn't throw any error. But http://jsbin.com/oZUHiXe/1#index1 throws error in console as index1 route is not available. How to handle this case?
Upvotes: 1
Views: 42
Reputation: 23322
You could define a catchall route using *
and do a redirect from there:
App.Router.map(function() {
this.route('catchAll', { path: '*:' });
});
App.CatchAllRoute = Ember.Route.extend({
redirect: function() {
alert('route not existen');
this.transitionTo('index');
}
});
Updated jsbin.
Hope it helps.
Upvotes: 3