Angular fallback route

How to configure Angular route to redirect to a default route if the user goes to a non existent route?

I’m working with Angular 11, following steps:

  1. Go into your app-routing.module.ts
  2. In your routes Array add a new object:

Mine looks like this:

That’s all, save and try to visit a URL that does not exist, you should be redirected.

Cheers!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store