1
有沒有辦法將組件中的字段綁定爲輸入和輸出?dart angular2 - 組件中的雙向綁定
即
<my-component [(innerComponentField)]="outerComponentField"></my-component>
感謝您的幫助。
有沒有辦法將組件中的字段綁定爲輸入和輸出?dart angular2 - 組件中的雙向綁定
即
<my-component [(innerComponentField)]="outerComponentField"></my-component>
感謝您的幫助。
對於[]
組件需要一個匹配@Input()
對於()
它需要一個匹配@Output()
。
沒有辦法只有一個@Input()
結合[(innerComponentFields)]
做到既需要
@Input() dynamic innerComponentField;
@Output() EventEmitter innerComponentFieldChange = new EventEmitter();
感謝您的幫助。你有這樣的代碼的例子嗎?我沒有在官方文檔中找到很多信息。 – matth3o
您是否檢查過https://angular.io/docs/dart/latest/guide/template-syntax.html#!#inputs-outputs –
Oups我的不好。它的工作原理,但我必須每次我的值更改時調用myEventEmitter.emit(),我必須在我的外部組件中實現一個方法來更新我的字段。謝謝你的幫助。 – matth3o