Search code examples
angularngrxangular-reactive-forms

How to prevent loop when setValue from store in radio button?


In reactive form I have radio buttons. During initialization one of them is selected base on data from store by setValue. When I change radio button by setValue - form.valueChanges is running and dispatch new action, but after that the infinite loop starts.

There is some way to checked radio button without event or prevent valueChanges?

enter image description here

How to selected radio button without execute valueChanges or prevent loop when value was change?


Solution

  • you can use setValue with options. something like this

    form.setValue(value, {emitEvent: false})