Safari Extension - AngularJS Model AutoFill Update

Im writing in the hope of figuring out how to call angularJS to update its model when doing autocomplete from browser extensions. I know that some other applications (password managers like LastPass) do this successfully.

I am creating a small Safari extension that will help me fill out the Apple form completely (funny). Sandbox. A user creation form that has 10 input fields and a couple of selector elements.

So far, I have managed to get input fields using jQuery and set their value using .val() . However, this does not cause angularJS to update its model, therefore, despite the presence of text in the input fields, angular believes that the text is missing and the form cannot be verified.

The problem can be easily fixed if I can access the angular object, but I seem to be unable to do this. My script input returns undefined when I try to access angular . So Im thinking that Im was either looking for the angular object incorrectly, or I have to solve it differently.

To note that I have already tried some other tricks mentioned on the Internet: input.trigger('input'); and other similar materials.

+6
source share
1 answer

It looks like you need to trick the form into thinking that you actually typed something into the input, instead of just setting the input value, which I believe is causing the focus event. Try using jQuery to focus and then focus the input. This should simulate a user click on the input field and exit the input field. If Apple builds its form correctly, this should lead to an update of the validation / model. Hope this helps.

0
source

All Articles