I have a text box that gets populated using javascript that is getting the data by reading a QR code and setting the value. I am using ng-model to bind to a variable in my controller which works fine when I type manually into the text box just not when it is populated with javascript. I am guessing there is some event I have to manually fire to trigger ng-model to do it's magic but I do not know what that event is or if it is even the right approach. My input looks like:
<input type="text" id="read" name="itemId" class="form-control center-block" placeholder="Item Id" ng-model="scannedId"/>
I am setting the value with the following once the QR code reading javascript does it's thing and works:
$('#read').val(data);
I have tried the following to try and manually trigger an event I hoped ng-model would be listening for right after assigning val(data) but both fail:
$('#read').trigger('input');
and
angular.element($('#reader')).triggerHandler('onChange');
Everything works fine if I type in it manually just not when updated with javascript. Thanks in advance!