Trying to get two way binding to work but getting the expression changed after it was checked exception. When mode changes to cancel and I want to reset the value to empty I get the exception. I assume it is because I am emitting inside of a change cycle with a different value but do not know how to avoid?
<edit-field [mode]="mode" [(field)]="field"></edit-field>
My component is:
export class EditFieldComponent implements OnChanges {
@Input('mode') mode: string;
@Input('field') field: string;
@Output('fieldChange') fieldChange: EventEmitter<string> = new EventEmitter<string>();
ngOnChanges() {
if(this.mode == 'cancel'){
this.field = "";
this.fieldChange.emit("");
}
}
}