Home > Software engineering >  Angular check if particular route path in URL
Angular check if particular route path in URL

Time:12-22

http://localhost:4200/dsc-ui/#message and if I type in the URL (remove #message and type application-management) http://localhost:4200/dsc-ui/application-management (/application-management), it should redirect me to http://localhost:4200/dsc-ui/#/application-management. For any other route stay on http://localhost:4200/dsc-ui/#message.

How can i achieve this using angular?

CodePudding user response:

You can set a new route in your Routes array in your router module, e.g.:

{ path: '/application-management', redirectTo: '/message', pathMatch: 'full' }

CodePudding user response:

Are you want to add dynamic routing in your project ? Or If you want to redirect you system if url is not existing in your system then find below code

{ path: '', pathMatch: "full", redirectTo: "/yourdefaultcomponent" },
  { path: '404', component: NotFoundComponent },
  { path: '**', redirectTo: '404' }
  • Related