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