Both have the same performance ngIf is a structural directive so it generates an ng-template around the element you place it and manipulates the gift accordingly. Thus in no case does it instantiate the component if ngIf is false. However there is a difference between semantics and style since the div has a display block and the component does not necessarily.
<componente *ngIf="hero" class="name">{{hero.name}}</componente>
flipped
<ng-template [ngIf]="hero">
<componente class="name">{{hero.name}}</componente >
</ng-template>
more information: Directive differences in Angular
Did you ever test whether the
ngIf
works within<componente></componente>
?– Albertt Santos
In reality both forms work... what I would like to know is if the <component> comes to be instantiated in the GIFT and then removed from the GIFT, or if it does not even enter in the GIFT. Another detail... in the example it is clearer if false is used... because the doubt is in loading the component. I do not know if it is clear.
– Erick Amaral