Create 404 page in Angular

1Create 404 page in Angular:

Prerequisites:

  1. Not found Component: Component to show for 404 page

2Code:

Module:

const routes: Routes = [
//your other routes
{path: 'not-found', component: NotFoundComponent, pathMatch:'full'},
{path: '**', redirectTo: 'not-found'},
];

@NgModule({
  imports: [
  RouterModule.forRoot(routes),
  ]
})

Component:

<h3>Oops! You're lost.</h3>
<p> We can not find the page you're looking for.</p>
<a [routerLink]="['/']"> Accueil </a>