change the character that separates a url (Angular)
I am obtaining the url with route.queryParams.subscribe and to separate the parameters I do it with Object.keys(params) where the latter separates them when it finds the "&". My question is, can I modify that separator, where I separate it when I find the character "$" for example and not the "&"?
The short code:
this.route.queryParams.subscribe(params => {
this.keys = Object.keys(params);
}
Example this url www.hi.com?v%2BRSC60dbdNliPmWIS8mbw%3D%3D=&uHW0Oj81Fug5ifNoPI4rGSpH5uaejSqrADBFSQhRU4fKQF3oIAXWRqtpv3TNsi3c7GDgva1P%2FozKCMFkd%2FDQEKqM1DBhmnV05psQ1n913EM5NjRNK53sEo60YxgVGky1bV%2BPB2C%2F1cG44b%2FrQPNmns7jWgQmWopQvO%2FCzWCD8o12HNQoINRzi%2FWsg9OUhoNncPl%2BU8OsJWUbKutTpW%2FiLHa4IQRvlSG59iyj6HVC2hwXwZnXVXGfDDTX3bP4Am4HQlO61CsaidcoF6mEVGSpLg%3D%3D=
when you go through the code above it looks like this, where "&" is the separator
0 : v%2BRSC60dbdNliPmWIS8mbw%3D%3D=
&
1: uHW0Oj81Fug5ifNoPI4rGSpH5uaejSqrADBFSQhRU4fKQF3oIAXWRqtpv3TNsi3c7GDgva1P%2FozKCMFkd%2FDQEKqM1DBhmnV05psQ1n913EM5NjRNK53sEo60YxgVGky1bV%2BPB2C%2F1cG44b%2FrQPNmns7jWgQmWopQvO%2FCzWCD8o12HNQoINRzi%2FWsg9OUhoNncPl%2BU8OsJWUbKutTpW%2FiLHa4IQRvlSG59iyj6HVC2hwXwZnXVXGfDDTX3bP4Am4HQlO61CsaidcoF6mEVGSpLg%3D%3D=
So, I want to know if there is a way to modify the separator character, for example instead of "&" they pass me the url with the character "$" for example and that I separate it in the same way.
This is Angular
Solution 1:
Just in case it is useful for you, you can use this:
in the imports
import { ActivatedRoute } from '@angular/router';
in your code
const id = Number(this.activatedRoute.snapshot.paramMap.get("id"));
lets suppouse your route is this one: http://localhost:4200/identification/:id