I have a situation where I need to display some content passed via ng-content with a selector to one of two areas. I have an ngIf that is used to check where to render the ng-content. The problem is that even if I have an ngIf in my first ng-content, the content will not be rendered in the second ng-content even if the condition for the first one is false. Here's an example of the issue:
<div>
<ng-content *ngIf="someBoolean" select="figure"></ng-content>
<div *ngIf="!someBoolean">
<ng-content select="figure"></ng-content>
</div>
</div>
This works fine if someBoolean is true. However, nothing will be inside the second div if someBoolean is false. What can I do to fix this? I found these two similar questions, but I tried all solutions and it does not work with Angular 6:
- https://github.com/angular/angular/issues/22972#issuecomment-407358396
- https://stackoverflow.com/a/41727533/10002144
- https://stackoverflow.com/a/44699654/10002144
Before you lock my question, I guarantee that I have tried all these solutions and they do not work on Angular 6 if you use selectors in ng-content.