I'm currently exploring options to specifically display the iframe
element within a block of HTML content being sent to my Angular application.
While I can use a *ngIf
directive in my template to check for the presence of the tag, I am unsure of how to isolate and only render the iframe from the content, excluding the rest of the HTML.
<div *ngIf="item.content.indexOf('iframe') > 0" class="item">
<div (click)="this.navigateToPost(item.id)">
<h2 [innerHTML]="item.title"></h2>
</div>
<div class="iframe-container"[innerHTML]="this.sanitized.bypassSecurityTrustHtml(item.content)">
</div>
</div>
Within the
<div class="iframe-container"[innerHTML]="this.sanitized.bypassSecurityTrustHtml(item.content)"></div>
, I am looking for a method to exclusively display the iframe code from the item.content
.
Does anyone have suggestions on how to approach this challenge effectively?