A
A
Andrew2018-06-26 23:16:14
JavaScript
Andrew, 2018-06-26 23:16:14

Angular 5, how to catch programmatically changing the value of an input?

There is an angular application, there is a library (datetimepicker) that changes the value of input. The problem is that angular does not see such changes. The change happens like this The model doesn't change. Angular event (change) doesn't fire. The event (blur) fires, but at the time of its occurrence, the input contains the old value. At the same time, the onchange js event works as it should. In the first Angular, this problem was solved by a simple call . But now it does not work. Has anyone encountered such a problem?
this.element.val(newValue).trigger('change');
$("selector").trigger("input");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny, 2018-06-26
Maltsev @maltsever

Hey! For such cases, you can either catch changes in ngOnChanges, or if there is only one input, then listen to changes through properties . It’s better to try not to use any jquery components, I also share this pain with you :)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question