1

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Ah ok.. then how can I pass the id.. is there another way than a router param?
@Mackelito, butting in here, but as to your question, do it like kemsky said in answer, store the id in your service, fetch it in the component you are navigating to :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.