I am working on a browser extension that will automatically click a button on a page. The code works on every site except ones with angularjs.
The following code is my attempt at clicking an angularjs button and have it register the click, but it does not work.
//applyButton is the button element.
if(angular) {
var e = angular.element(applyButton);
e.trigger('click');
e.scope().$apply();
} else {
applyButton.click();
}
Here is the angular html code for the applyButton that is not registering the "click"
<input value="Apply" class="apply button gift-card-apply" data-ng-click="!orderSubmitErrors.giftCard.sectionHasErrors && applyGiftCard($event)" client-validation="onSubmit,giftCard,validateSubsection" type="button">
Is there a best practice to click buttons and change input fields for angularjs from javascript if I only have access to the document.element for those items?