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

251
Vistas
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 Respuestas
Responde la pregunta

0

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

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