[英]How to pass input and output parameters in Angular2 rc4 in dynamically created component
我有一個想要傳遞幾個參數的組件:
<sentence [sentence]="text.title" [selectedWord]="selectedWord" (selectionChanged)="selectionChanged($event)"></sentence>
我正在使用以下代碼動態創建組件:
addComponent() {
this.compiler.resolveComponent(TaskHeaderComponent).then((factory) =>
this.cmpRef = this.viewContainer.createComponent(factory, 0, this.viewContainer.injector));
}
我如何傳遞給創建的組件:
TIA
沒有綁定支持dor動態添加的元素,但是您可以強制執行
this.cmpRef.instance.sentence = ...
this.cmpRef.instance.selectionChange.subscribe(...)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.