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

252
Visualizações
getElementById(param) is not working in angular when trying to use dinamic param

I'm trying to use getElementById("id"+i) where de "i" is imported from an *ngIf, I get the correct parameter for de getElementById("id"+i) but when using it, it appears as "unDefined"

 sendDeleteRequest( id: string): Observable<any> {const requestOptions: Object = {
          
          responseType: 'text'
        }
        return this.http.delete<any>(`https://arg-prog-backend.herokuapp.com/educacion/borrar/${id}`, requestOptions);
      }
      delete_paragraph(i : number){
        const elementId = i
        const elementIdStr= elementId.toString()
        const id =(<HTMLInputElement>document.getElementById(elementIdStr))?.value;
        this.sendDeleteRequest(id).subscribe((res:any)=>{});
        console.log(elementIdStr)
      }

and the HTML code:


<h3 style="display: block;" id = "{{i}}" >{{educacion?.id}}</h3>
                            <h2>{{educacion?.school}}</h2>  <h3>{{educacion?.years}}</h3>
                            <p>{{educacion?.carreer}}</p>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you want to get getElementById("id"+i), your html should be: id="id{{i}}".

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