I have a string that contains the following HTML code:
<div>
<TextSubtitle [color]="'#B3B4B4'" [bold]="'true'">Datos Personales del Solicitante</TextSubtitle>
<div style="margin-top: 20px;display: flex;justify-content: space-between">
<InputItem style="width: 47%" [label]="'Primer nombre *'"></InputItem>
<InputItem style="width: 47%" [label]="'Segundo nombre *'"></InputItem>
</div>
<div style="margin-top: 10px;display: flex;justify-content: space-between">
<InputItem style="width: 47%" [label]="'Apellido paterno *'"></InputItem>
<InputItem style="width: 47%" [label]="'Apellido materno *'"></InputItem>
</div>
<div style="margin-top: 10px;display: flex;justify-content: space-between">
<InputItem style="width: 47%" [label]="'Fecha de nacimiento *'"></InputItem>
<InputItem style="width: 47%" [label]="'Género *'"></InputItem>
</div>
<div style="margin-top: 10px;display: flex;justify-content: space-between">
<InputItem style="width: 47%" [label]="'Ocupación *'"></InputItem>
<InputItem style="width: 47%" [label]="'Dependientes económicos *'"></InputItem>
</div>
<div style="margin-top: 10px;display: flex;justify-content: space-between">
<InputItem style="width: 47%" [label]="'Estado civil *'"></InputItem>
<InputItem style="width: 47%" [label]="'Número de hijos *'"></InputItem>
</div>
<div style="margin-top: 10px;display: flex;justify-content: space-between">
<InputItem style="width: 47%" [label]="'RFC *'"></InputItem>
<InputItem style="width: 47%" [label]="'CURP *'"></InputItem>
</div>
</div>
note: InputItem is a angular component I build
I am trying to insert the entire string as HTML code in my HTML file
typescript file:
ngOnInit() {
this.doc = new DOMParser().parseFromString(myString, "text/html");
}
HTML file:
<div>
{{doc.firstChild.innerHTML}}
</div>
this will print the actually HTML code as a string on screen.