How to define wildcard route in angular? I have to show page not found component if the URL doesn’t match anything.
If the URL doesn’t match any predefined routes then it causes the router to throw an error and crash the app. In this case, you can use a wildcard route. A wildcard route has a path consisting of two asterisks to match every URL.
For example, you can define PageNotFoundComponent for wildcard route as below:
{ path: '**', component: PageNotFoundComponent }