7
条件内容投影(包含)我想提供,如果内容没有transcluded,只会显示默认的内容。是否有可能做角2+
例如这里是我的组件模板:
<article>
<header>
<ng-content select="[header]"></ng-content>
</header>
<section>
<ng-content></ng-content>
</section>
</article>
我可以这样使用它:
<my-component>
<h1 header>This is my header</h1>
<p>This is my content</p>
</my-component>
现在,如果我想提供一个默认的标题。可能吗;不象检查在ngAfterContentInit
内容杂技?
看看这个答案http://stackoverflow.com/a/38692980/373655。不知道一个更优雅的解决方案存在不要求'ngAfterContentInit' – rob
另外,你能别名投影? '' –
Cody