Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

175
Visualizações
If there is a word in the results that match the word I am looking for in the array, how can I show it in color?

for example i am searching "TEST" and in the results "THIS IS A TEST" if it writes i need to color the background of TEST text in this result

here is my code;

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)
  })}

my purpose here is if there is "LEKE" in the Array, enclose it in span tags and change its background. asd

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

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

on your template for loop, all the matches will be inside a span tag

<p [innerHTML]="mappedSubtitle"></p>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda