O'Reilly logo

Learning Web Development with Bootstrap and AngularJS by Stephen Radford

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The fallback route

The last route we need to configure is the one that will show when no route is matched. You could create a 404 page for this, but let's take a look at how we can redirect a route instead of displaying a template.

To create our fallback route, we use the second method that the $routeProvider service gives us—otherwise:

.otherwise({
    redirectTo: '/'
});

Now, if the requested route doesn't match any of the ones defined in our router, Angular will redirect us back to our index page.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required