What is a wildcard route (**)?
A wildcard route (**) is a catch-all route that intercepts every path that did not match any of the defined routes.
It's usually used:
- for 404 pages - when the path does not exist;
- to redirect the user to a default component or route.
Example:
typescript
const routes: Routes = [
{ path: 'home', component: HomeComponent },
{ path: '**', component: NotFoundComponent }
];In this example, any unrecognized URL (for example, /abrakadabra) will result in NotFoundComponent being rendered.
Important: the wildcard route is always placed at the end of the list, because Angular checks routes from top to bottom.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.