Reputation: 237
Demo: https://stackblitz.com/edit/angular-svpg8g
I have some third part component (ThirdPartCounter
in the app/counter.component.ts
). I've wrapped it into the Angular component and subscribed on changing of this counter. When I interact with counter UI (Increment
button) I have correct events in my stream. But! If I setup counter value manually (Clear
button) I have duplicate of event in this stream (one is because component changing, next called after writeValue
).
How should I prevent excess event after writeValue
callback?
Upvotes: 1
Views: 616
Reputation: 21387
try this , it will not duplicate with emitEvent to false
clear() {
this.myForm.controls['counter'].patchValue(0, {emitEvent : false});
}
check it here https://stackblitz.com/edit/angular-dc8cyl
Upvotes: 1