Mackelito
Mackelito

Reputation: 4421

Angular router url without param

I want to use id when requesting data but not show it id url.

[routerLink]="['/', category.slug, {id: category.categoryId}]"

This results in url '/cameras;id=3' where id 3 is the cameras category. It works but I would like to have a clean url like '/cameras' only

Upvotes: 1

Views: 409

Answers (1)

kemsky
kemsky

Reputation: 15261

Parameters are encoded in url (you can even customize this encoding), but it is not possible to hide them, hiding in this case === completely removing.

You may use workaround using shared service and pass parameters using this service when navigating within application, but in this case you will not be able to share links, because it will not contain parameter value.

Upvotes: 1

Related Questions