html:
<div [innerHTML]="answerPanelContent"></div>
ts:
import { Component, Renderer2, ElementRef, OnInit } from '@angular/core';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: [ './app.component.css' ]
})
export class AppComponent implements OnInit {
constructor( private renderer:Renderer2,
private el:ElementRef) { }
ngOnInit() {
const button = this.renderer.createElement('button');
const buttonText = this.renderer.createText('Click me');
this.renderer.appendChild(button, buttonText);
this.renderer.appendChild(this.el.nativeElement, button);
this.renderer.listen(button, 'click', () => {alert('hi');});
}
}
Вы можете написать каждое событие в {alert ('hi'); ......}