Simple question:
The Angular docs suggest not using ng-content in the case of conditional rendering on the component end:
If your component needs to conditionally render content, or render content multiple times, you should configure that component to accept an element that contains the content you want to conditionally render.
Using an element in these cases is not recommended, because when the consumer of a component supplies the content, that content is always initialized, even if the component does not define an element or if that element is inside of an ngIf statement. From:
You can try to change the
ngIf
totrue
to see how it appears in the DOM (and the custom directive gets initialized as well, which won't if thengIf
is false)