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

130
Views
Desaparece el atributo id del valor innerHTML

Estoy tratando de configurar el contenido de un DOM-Element con innerHTML, pero no funciona como esperaba. El contenido que quiero configurar es una etiqueta con id y href como atributos, sin embargo, el atributo id no está en el contenido representado.

Código de ejemplo:

 import { Component } from '@angular/core'; @Component({ selector: 'app-root', template: `<div [innerHTML]="html"></div>`, styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'Angular'; html = '<a href="/" id="foo">link</a>'; }

Cualquier ayuda es bienvenida.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Debe usar el método bypassSecurityTrustHtml para decirle a angular que este html es seguro de usar.

 html = this.sanitizer.bypassSecurityTrustHtml('<a href="/" id="foo">link</a>'); constructor(private sanitizer: DomSanitizer){}

Apilamiento de trabajo

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!