Search code examples
angularangular-ng-if

Angular 2+ ngIf Not Stopping Child Component From Building


I have a parent component that calls in child component. I want an ngIf check to show/build or hide/don't build child component... no matter what the component is built even when not displayed (not in dom). Is there another way to stop this from happening?

Parent HTML Template:

<div>
  <child-comp *ngIf="1 == 0"></child-comp>
</div>

I am thinking that ngIf won't get me where I want to be.


Solution

  • Put your ngIf check in the outer div around your child-comp