I
I
insanel2020-10-15 13:26:39
Angular
insanel, 2020-10-15 13:26:39

How to track variable change in angular?

I have variables from a form that are found in another controller

I access via:
this.exampleForm.controls.x.value

How do I track this variable's change and call a method if it changes?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shvets, 2020-10-15
@insanel

It's funny, but for some reason such an obvious and often used thing is missing in most articles about the basics of reactive forms.
In addition value, every control has an observable valueChanges. Subscribe to it and get updates.
And the group also has, you will get a change of the whole group.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question