404 Error Handling Angular

Starting a new project
First use your terminal to navigate to a directory that will be the parent directory of your project, then run this command:
code:-

ng new app-name

Serve project

code:-

ng serve
Add a 404 page
code:-
ng g component notfound

Change in-app routing

code:-

import { NotfoundComponent } from './notfound/notfound.component';

const routes: Routes = [
    { path: '**',  component: NotfoundComponent },
  ]

Change in notfound.component.html

code:-

<h1>404</h1>