讓我們說我有以下的基本組成部分有兩個插槽:多插槽轉換與Angular 2組件一起工作嗎?
// my-component.component.ts
@Component({
selector: 'my-component',
template: `
<div class="my-component">
<div>
Title:
<ng-content select="my-component-title"></ng-content>
</div>
<div>
Content:
<ng-content select="my-component-content"></ng-content>
</div>
</div>`
})
進入第二插槽(「我的成分含量」)我想插入規則的角2組件...
<div class="app">
<my-component>
<div class="my-component">
<div>
Title:
<my-component-title>
This is the Component title!
</my-component-title>
</div>
<div>
Content:
<my-component-content>
<some-regular-angular2-component></some-regular-angular2-component>
</my-component-content>
</div>
</div>
</my-component>
</div>
在哪裏一些-常規angular2成分'是一些角2成分的選擇器...
@Component({
selector:'some-regular-angular2-component'
})'
問題是,「一些-常規angular2-COMPONE nt'永遠不會被轉換到ng-content的第二個槽中......只有普通的HTML適用於我...我試圖將'some-regular-angular2-component'設置爲父組件的[directive],但Angular 2組件無法在ng內容中識別...或者這對你有用嗎?
你可以發表一個你認爲應該工作的樣本plunk或jsfiddle嗎?你的父'@ Component'裝飾器的'directives'中列出了'some-regular-angular2-component'類嗎?那必須在那裏。 –