Wildcard Routes
Explore how to configure wildcard routes in Angular to handle invalid URLs gracefully. Learn to set '**' as a path to catch unknown routes and display a custom Page Not Found component, enhancing user experience.
What are the wildcard routes?
Another important part of defining Routes in our application is setting up wildcard routes.
Wildcard routes are how we tell Angular how to handle invalid URLs and what to do with them.
An invalid URL could be where the user mistypes the name of a path.
Example: Navigating an invalid route
For example, we know that http://localhost:4200/clients is a valid path in our Client Contact Manager application, but http://localhost:4200/client isn’t because we don’t have a route in our Routes array that matches that exact /client route. If the user was to add that into the browser’s address bar, our application would throw an error saying that this path is not recognized. ...