Answer the question
In order to leave comments, you need to log in
How to change ngModel if we change the input not in the context of angular 2?
There is a component, in the layout there is an input tied through [(ngModel)] to the field of the component class. Let's say we change the value of the input through a third-party script. For example JQuery through $('input').val("value"), then in angular the value of the model does not change. How to rebind or something else to pick up this change?
Answer the question
In order to leave comments, you need to log in
you may also need to trigger the Input event on the element.
Here you can see the implementation features of ngModel for the standard input
You can try this one . And so the third-party script also has an event, can it bind through it?
ngModel is not a reference to the same memory area, but "syntactic sugar".
When the input value changes, an event occurs, which allows you to use two-way binding.
https://metanit.com/web/angular2/5.2.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question