简体   繁体   中英

Angular check if particular route path in URL

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?

You can set a new route in your Routes array in your router module, eg:

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

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' }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM