Angular – ng-star-inserted

On some occasions your *ngIf-statement can wrap the children of that element in a class="ng-star-inserted"

This can really hurt your layout, although there is a quick fix!
You have add an <ng-container> where you write the if-statement.

Instead of using: 

<div *ngIf="1 == 1">
   ...
 </div>

You should use

<ng-container *ngIf="1 == 1">
  <div>
    ...
  </div>
</ng-container>

It’s bad practice for dom cleansiness setting an *ngIf on any other element then an ng-container.

Leave a Reply