I would like to set input value (in Vanilla JS) in website created in Agnular.
when I try to do:
document.querySelector('my_input').value = 'value';
the value shows in input but searching doesn't see this value (form is submitted but it looks like my input is empty).
I see that there is event ngModelChange.
Is there any option to do something like that:
document.querySelector('my_input').dispatchEvent(new Event('ngModelChange', {value: 'value'}));
If I do that i get in input [object Event] and the form searching get this value.
Any ideas?
I solved my problem. This code works for me:
document.querySelector('my_input').value = 'my_value';
document.querySelector('my_input').dispatchEvent(new Event('input'));
document.querySelector('my_input').dispatchEvent(new Event('blur'));
Thanks for you answers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With