Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

249
Views
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 answers
Answer question

0

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

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!