简体   繁体   中英

Routing URL is not working as previous in angular 7

Routing module Path configuration

{ path: 'invite/:token', component: PreAuthComponent },

Previously we were using

localhost:4200/#/invite/?key=12345

but after update to angular 7 it's not taking both /? combine and not able to navigate. How to achieve this with same configuration mentioned above.

currently working URL's with different configuration

{ path: 'invite/:token', component: PreAuthComponent }

localhost:4200/#/invite/12345

or

{ path: 'invite', component: PreAuthComponent }

localhost:4200/#/invite?key=12345

According to Locationstrategy , you may update the LocationStrategy by set useHash: true in RouterModule.forRoot() method as following.

RouterModule.forRoot(routes, { useHash: true })  // .../#/crisis-center/

By the way, the route parameter ("/feature/:id") and query parameter ("feature?key=value") is very different in Angular. route parameter can be used for routing and processed by component. Usually, query parameter is only processed in NgComponent.

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