2

I'm wonder if there's a way to know the difference whether valueChanges on a FormControl was triggered from the dom or the component itself. My use case is I need to do stuff() when the user changes the value, but I don't want to do stuff() if the value changed as a result of something else. Any thoughts?

1
  • I don't understand the downvotes. This is an interesting question. Unfortunately I am pretty sure that this kind of API does not exist. Commented Apr 11, 2018 at 22:03

2 Answers 2

1

with the control ".touched"

EXAMPLE: YourModelForm.get('YourField').touched

the value becomes true when the user enters a value (first click on the field, enter the value, tab or click out of the field).

I tried with a call rest and the value remains to false, try it if you can possibly it works for your situation. :-)

Sign up to request clarification or add additional context in comments.

Comments

1

Thanks to @Nobady, who inspired the idea. I found there's actually an option for setValue on the formControl called emitEvent. Using this, I can make it so if I update the value programmatically I can bypass the valueChanges getting called.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.