1/* 404 Page not found page setup in Angular Routing */
2
3$ ng generate component notfound
4
5Next, open the src/app/app-routing.module.ts file and add these two routes:
6
7const routes: Routes = [
8 // [...]
9 {path: '404', component: NotFoundComponent},
10 {path: '**', redirectTo: '/404'}
11
12];
13
14Don't forget to import the component in the routing module as follows:
15
16import { NotFoundComponent } from './notfound/notfound.component';
17
18We use the wildcard path denoted by ** to catch any non existing routes and we use the redirectTo property to redirect them to the /404 path which maps to the not found component.