How do you handle 404 pages and redirects?
Model answer
Add a wildcard route at the end: { path: '**', component: NotFoundPage }. Routes are matched in order, so it must be last. For redirects use { path: '', redirectTo: 'home', pathMatch: 'full' }, where pathMatch full makes the redirect apply only to the empty path.
For missing data (such as a user id that does not exist), show a not-found state, and for server-rendered apps make sure the server also returns a real 404 status.
Learn this topic
Angular Tutorial: Beginner to Advanced .
Sign in to add your own answer.