我想在 Angular 中使用反應形式進行雙向系結。我想將資料從子組件傳輸到父組件并回傳。
我的子組件 HTML:
<input type="text" #name class="form-control"
(keydown)="oss.test(); addNewItem(name.value)" formControlName="name">
我的子組件 TypeScript:
@Input() namex: string= "";
@Output() additem = new EventEmitter<string>();
父組件 HTML:
<app-general [(count)]="count" [(namex)]="currentItem" (value)="this.generalInformation=$event; this.print()"
(isValid)="this.generalInformationIsValid=$event">
</app-general>
父組件 TypeScript:
currentItem: string = "";
我收到以下錯誤訊息:
The property and event halves of the two-way binding 'namex' are not bound to the same target.
Find more at https://angular.io/guide/two-way-binding#how-two-way-binding-works
有人可以幫我為什么會收到此錯誤嗎?
我想將資料從子組件獲取到父組件并回傳。
uj5u.com熱心網友回復:
你有 @Input() namex: string = ""; 如果沒有 @Output() namexChange = new EventEmitter(),請嘗試添加 namexChange 事件
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/523431.html
標籤:有角度的打字稿角反应形式