Migrated from Angular 11 to Angular 12 and this issue pops out:
"Error: The property and event halves of the two-way binding 'value' are not bound to the same target."
Parent Page Component:
import { Component } from '@angular/core';
@Component({
selector: 'app-parent',
template: `
<app-child [(value)]="counterValue"></app-child>
`,
styles: []
})
export class ParentComponent {
counterValue = 0;
}
Child Component:
import { Component, OnInit, EventEmitter, Input, Output } from '@angular/core';
@Component({
selector: 'app-child',
template: `
{{ value }}
`,
styles: []
})
export class ChildComponent {
@Input() value = 0;
@Output() incrementValue = new EventEmitter<number>();
increase(): void {
this.value++;
this.incrementValue.emit(this.value);
}
}
Here es a stackblitz code for you to test it your self:
Is this a bug? or am I missing something?