(Angular 2+)ng-content投影而不渲染选择器容器

时间:2017-02-13 06:30:57

标签: angular projection

可以通过以下方式使用<ng-content>吗?

定义:

<th>title</th>
<ng-content select="[stuff]"></ng-content>

使用:

<div stuff>
    <th>category</th>
</div>

生成的HTML不包含<div stuff>

<th>title</th>
<th>category</th>

1 个答案:

答案 0 :(得分:1)

这可以通过使用ng-container

来实现

<div stuff>替换为<ng-container stuff>应该可以

示例https://stackblitz.com/edit/angular-hhimgu