Angular
Frontend framework with template-like syntax
innerHTML
elem.innerHTML = `<p>${input}</p>`<p [innerHTML]="input"></p>constructor(private sanitizer: DomSanitizer) {
this.input = this.sanitizer.bypassSecurityTrustHtml("<img src onerror=alert(origin)>");
}@ViewChild("p") p: ElementRef | undefined;
ngAfterViewInit() {
const html = new DOMParser().parseFromString("<img src onerror=alert(origin)>", "text/html").body.firstChild;
this.p?.nativeElement.appendChild(html);
}Last updated