I have a problem with a new conclusion ng-content.
Let's say I have a component my-componentthat in its function ngOnInit()performs some heavy operation at boot (currently just a console.log()).
I have a wrapper that displays content through a transition ( my-wrapper.component.html).
<ng-content></ng-content>
If I set the environment this way, the log statement does not show:
<my-wrapper *ngIf="false">
<my-component></my-component>
</my-wrapper>
I assume that the component is my-wrappernot created, so the content is ignored.
But if I try to move the logic to a component my-wrapperlike this ( my-wrapper.component.html):
<ng-container *ngIf="false">
<ng-content></ng-content>
</ng-container>
console.log(). , my-component , , *ngIf true my-wrapper.
" + ". , N (my-wrapper), *ngFor. (my-component), , .
overview.html:
<ng-container *ngFor="let item of items">
<my-wrapper>
<my-component id="item.id"></my-component>
</my-wrapper>
</ng-container>
-wrapper.component.html:
<div (click)="toggleDetail()">Click for more</div>
<div *ngIf="showDetail">
<ng-content></ng-content>
</div>
Angular, , ? , AngularJS.