I have a formbuilder group and am listening for changes with valueChanges and triggering a save function followed by refresh function on the form:
this.ticketForm.valueChanges.debounceTime(1000).distinctUntilChanged()
.subscribe(data => {
this.saveTicket();
this.refreshTicket();
})
I am then reloading the form and repatching the data to form fields (and elsewhere on the page, particularly a change log) with patchValue, e.g.:
this.ticketForm.patchValue(ticket, { emitEvent: false });
however, this causes an infinite loop of saves of the form despite emitEvent : false.
Is this an Angular 4/Ionic 3 bug or a misunderstanding on my part?
Try adding onlySelf: true
along with the emitEvent: false
in this way:
this.ticketForm.patchValue(ticket, {emitEvent: false, onlySelf: true});