简单的问题:
Angular 文档建议不要在组件端进行条件渲染的情况下使用 ng-content :
如果您的组件需要有条件地呈现内容,或多次呈现内容,您应该将该组件配置为接受包含您想要有条件地呈现的内容的元素。
不建议在这些情况下使用元素,因为当组件的使用者提供内容时,该内容始终会被初始化,即使组件没有定义元素或者该元素位于 ngIf 语句中。来自:https ://angular.io/guide/content-projection#conditional-content-projection
这是否也适用于组件槽的消费者?例如:
<custom-table-component>
<div ng-content-select-directive *ngIf="condition">
This is a conditionally rendered element inhabiting an ng-content slot of a parent
component
</div>
</custom-table-component>
如果条件不成立,底层的 ng-content-select 是否仍会被渲染?