• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

181
Vistas
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

almost 3 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

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

almost 3 years ago · Juan Pablo Isaza Denunciar

0

Why not use simple do:

string.split("any character you want")

It will return list of array of the string splitted at "any character you want". Or find the index using:

string.indexOf("any character you want")

Then splice the string accoordingly. You can even loop the string and return the index using array.forEach and splice it at that position.

almost 3 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda