Use $timeout to make sure your model gets synchronized with the UI. 
Something like this would do if you call it right after assigning the a new 
value to your field:

$timeout(function(){});


Still I'm not sure why you're not building your own directive instead of 
having a half-baked solution where you use a bit of Angular with a bit of 
"manual" DOM manipulation. 

On Sunday, July 19, 2015 at 2:39:10 PM UTC-7, Dan Savage wrote:
>
> I'm trying to run javascript in a browser extension to automate a process 
> of filling in a form on a website and then clicking a button -- the 
> extension code can be simulated by typing javascript:code into the address 
> bar.
>
> The website that I'm having problems with uses angularJS. I have the names 
> of the input field ids and am using those to change the input field values. 
> The fields fill up but when I click the button it says they are not filled, 
> there are no values and they are all in error. Some validation is going on 
> that does not "see" my javascript changes unless I type in the values 
> manually.
>
>
> Is there a simple way to change the value of the AngularJS input fields 
> that have validation using just the id of the input field.
>
>
>
> Here is the code that's causing me problems from the webpage. When the 
> extension is running I will not have access to the source code so I can 
> only do "javascript" types of things.
>
>
> <input id="shippingAddr-first-name" type="text" class="first-name ng-pristine 
> ng-valid" maxlength="16" data-ng-model="addressTypes[addressType].FirstName" 
> focus-me="commonAddressTypeProps[addressType].focusOnFirstName" 
> client-validation="onExit" data-required-on-exit="">
>
>
> My attempts using 
>
> document.getElementById("shippingAddr-first-name").value="Dave";  change 
> the field but do not register correctly during the form submission. 
>
>
> It does work however if I type it in manually with the mouse and keyboard.
>
>
> I've also tried click(),blur(),focus(), to simulate some things I might be 
> doing manually but those do not work either.
>
>
> Is there a way to change an input value using javascript when the code is 
> running angularJS?
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to