I am using a hash location strategy in Angular
routing.module.ts
@NgModule({
imports: [
RouterModule.forRoot(routes, { useHash: true })
],
exports: [
RouterModule
]
})
app.module.ts
@NgModule({
providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy }]
})
I am routing from some other application to my angular application with this URL
HTTP://localhost:4200?param_x=xyz¶m_y=abc
I want to get values of these params in my application, how do I do that?
I tried using Activated route snapshot as well as subscribe, both give me empty values.
Please open your client side with fragment params.
Fragment params are parameters after # - also called as client params because they arent sent to the server.
HTTP://localhost:4200?#hash_param_x=xyz&hash_param_y=abc
Then access them via:
this.activatedRoute.snapshot.queryParams
HashLocationStrategy
takes the hash(fragment/client) params and insert them into query params. Since you don't have any, you don't see any params.