I am using a Angular 6 js script which I purchased without access to the underlying readable code. The js code I can see is webpack. I want to make a few small additions with plain js or jq. Specifically, I want to programmatically set values of input elements. In jq: $(selector).val(value). As I don't have access to the source code, I must add a custom js script to manipulate the input.
This is what I have tried:
$(selector).val(value), both in jq and in plain js. All to no
avail.Any other suggestions how to go about this?
After some trial and error, I found this to be working for Angular 12:
const input = document.querySelector(selector);
input.value = value;
input.dispatchEvent(new Event("input"));
In jQuery this would be something like:
$(selector).val(value).trigger("input");