我想用角度上的反应形式进行双向绑定。我希望将数据从子组件传输到父组件并返回。
我的子组件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
有人能帮我解释一下为什么我会犯这个错误吗?
我希望从子组件获取数据到父组件并返回。
发布于 2022-10-31 13:41:56
您有@ the () namex: string = "";如果没有@Output() namexChange =新的EventEmitter(),尝试添加namexChange事件
https://stackoverflow.com/questions/74263463
复制相似问题