Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
Si hay una palabra en los resultados que coincide con la palabra que estoy buscando en la matriz, ¿cómo puedo mostrarla en color?

por ejemplo, estoy buscando "PRUEBA" y en los resultados "ESTO ES UNA PRUEBA" si escribe necesito colorear el fondo del texto de PRUEBA en este resultado

aquí está mi código;

 this.searchControl.valueChanges .pipe( distinctUntilChanged() ) .subscribe((query: string) => { this.filteredSubtitles = [] this.docViewerServiceService.getSubTitles .map(o => o.subTitle) .forEach(o => { //searching part const filtered = o.filter(subtitle => subtitle.toLocaleLowerCase().includes(query.trim().toLocaleLowerCase())) this.filteredSubtitles.push([...filtered]); //Matching part of the searched word with the word in the string this.filteredSubtitles.find(o => { if (o.filter(a => a.includes(query))) { yes i'm stuck here there is no need for this if maybe but i don't know } }); }) //as a whole to divide the words in the string we get and the time range into strings. this.filteredSubtitles.forEach(findedSubTitles => this.pushFindedTitles = findedSubTitles) })}

mi propósito aquí es si hay "LEKE" en la matriz, encerrarlo en etiquetas de intervalo y cambiar su fondo. asd

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

this.docViewerServiceService.getSubTitles.map((o) => { return o.subTitle.replace( new RegExp(query.trim().toLocaleLowerCase(), i), (match) => { return `<span>${match}</span>`; } ); });

en su plantilla for loop, todas las coincidencias estarán dentro de una etiqueta de intervalo

 <p [innerHTML]="mappedSubtitle"></p>
about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda