I've a json file
{
"articles": [
{
"id": 1,
"title": "<h1>How to install Atom</h1>"
},
{
"id": 2,
"title": "<h1>Installing Boostrap</h1>"
}
]
}
I am using json-server
with angular 8
to read this json. As you can see title
field is supposed to be an html head tag when rendered on screen. But it is getting printed as it is. See, this is what I am trying to say.
. I want to convert this into heading-1 tag in run time. My
app.component.html
is
<div id="data-container">
</div>
Hello
<table>
<tr *ngFor="let art of lstcomments">
<td>{{art.id}}</td>
<td>
document.querySelector('#data-container').innerHTML={{art.title}}
</td>
</tr>
</table>
</div>
<router-outlet></router-outlet>
My title
is stored in {{ art.title }}
. I tried creating a separate div
with id data-container
and used document.querySelector
but the whole code gets printed as a string. What should I do now.