0

I need to conditionally add an extra html as a div content. For now I did it this way:

before:

<div *ngFor="let cell of cells" class="cell"
    [innerHTML]="cell.dataWithHtml"
></div>

after:

<div *ngFor="let cell of cells" class="cell">
    <img *ngIf="cell.isSpecial" src="whatever"/>
    <div class="this_div_should_not_exist" [innerHTML]="cell.dataWithHtml"></div>
</div>

But this adds an extra div.

How this block can be rewritten without adding extra div?

Sergej
  • 2,030
  • 1
  • 18
  • 28

1 Answers1

1

Use outerHTML on the div you wish to disappear/replace - you can't use ng-container.

<div class="this_div_should_not_exist" [outerHTML]="cell.dataWithHtml"></div>
Ash
  • 11,292
  • 4
  • 27
  • 34