1

I am trying to write Chrome extension which allows me to login to Angular Application. Application is built in prod mode. I fill up username and password input fields programmatically

document.getElementById('username').value = 'User Name';
document.getElementById('password').value = 'pass';
document.getElementById('submit').click();

But Submit button is inactive because validation isn't passed but validation isn't passed because Change Detection wasn't run too.

My question is how to run Change Detection of Angular App outside App?

vorant
  • 708
  • 5
  • 15
  • Why do not you use reactive forms instead?? Check the tutorial here. https://angular.io/guide/reactive-forms About change detection you can user the ChangeDetectorRef class. More info here. https://angular.io/api/core/ChangeDetectorRef – Σωτήρης Ραφαήλ Apr 15 '19 at 07:45
  • I don't have access to Angular code at all. I can manipulate it from chrome extension. – vorant Apr 15 '19 at 07:49
  • 1
    Instead of (or on top of) just setting the values, try dispatching an `input` event on the inputs. – mbojko Apr 15 '19 at 07:49
  • @mbojko could you provide an example? – vorant Apr 15 '19 at 08:00
  • Generally, I thought of something like this: https://stackoverflow.com/questions/2490825/how-to-trigger-event-in-javascript – mbojko Apr 15 '19 at 08:33

0 Answers0