Seems not safe to use innerHTML, there is another technique to inject or insert HTML from an array?
let's said I've an array with html content, like:
const ItemSections: ItemSection[] = [
{
heading: "Lorem",
SectionHTML: `
<h3>Lorem ipsum dolor sit amet</h3>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
<p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>,
id: "Lorem"
},
{
heading: "ipsum",
SectionHTML: `
<h3>Ipsum amet</h3>
<p>Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>,
id: "ipsum"
}
];
template of component
<section class="row" *ngFor="let section of lItemSection">
<aside class="col-md-4 col-xs-12">
<h3>{{section.heading}}</h3>
</aside><!-- /col -->
<aside class="col-md-8 col-xs-12">
<p>{{section.SectionHTML}}</p>
</aside><!-- /col -->
</section>
However, the technique above render html tags
if I use the innerHTML works great, like:
<div [innerHTML]="section.SectionHTML"></div>
but exposes the app to XSS security risks!
suggestions??