skip to Main Content

I want to set a header 404 on current page when there is no route matching my array.

Other wise I think it will be a issue in SEO and unknown pages will also be added to search engines.

2

Answers


  1. Angular has a route path – **, which will be accessed if no route was matched. You can use this path to show 404 error page component.

    { path: '**', component: Error404Component }
    
    Login or Signup to reply.
  2. you can do like this , add below in your rout.ts file and create notfoundComponent

     {path: '404', component: NotFoundComponent},
     {path: '**', redirectTo: '/404'}
    
    or you can do directly 
    
     {path: '**', component: NotFoundComponent}
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search