I'm trying to set a value of an Angular textarea using a Chrome extension. As this is a Chrome extension, I do not have access to the website's source and so cannot use Angular directives.
A quick background to what I'm trying to achieve, I have a drop down box where I can select values, selecting a value from the drop box will call a javascript function to populate a textarea with the value selected from the drop down control.
I can get the text to update on the Angular textarea by getting the ID of the element and setting it with the .val() method, however setting the values programmatically does not set the "isdirty" method of of Angular textarea.
I have seen that the "isdirty" property can be set manually by using triggers to emulate input on the textarea but it does not seem to work as the textarea's "ng-untouched" value is still set. Only when I click on the textarea (after the .val() function is called and the textarea is now populated) and click out of it does the "ng-touched" value get set.
I just have a basic selector as so
var notes = $("#notes").val();
notes.trigger("change");
I have tried using the following keywords within the trigger method, and also tried using them directly (i.e. .change() etc), keyup, onkeyup, input, change, and none of them works for me.
$('#notes').get(0).change();
There are no error showing on dev tools.
Is there something that I'm missing which is preventing this from happening?