2

I have some inputs that I'm trying fill using a Chrome snippet. The inputs that are bound to the component model using [(ngModel)]="myProperty" work great. Two of the inputs, however, only update the component model on blur (I want one-way template to model binding, which does not appear to exist).

For example: <input id="myId" (blur)="blurs = blurs + 1">

The following script enters the text just fine but does not trigger the blur, and therefore does not update the model:

document.querySelector('#myId').select();
document.execCommand('insertText', false, 'some text');
document.getElementById("myId").focus();
document.getElementById("myId").blur();

Example on StackBlitz

I've tried adding a tabindex with no success.

Any ideas?

alexleen
  • 125
  • 1
  • 2
  • 8
  • See https://stackoverflow.com/questions/14783585/jquery-focus-command-doesnt-work-from-chrome-command-line and https://stackoverflow.com/questions/1096436/document-getelementbyidid-focus-is-not-working-for-firefox-or-chrome – yurzui Feb 26 '19 at 19:27
  • @yurzui [this answer](https://stackoverflow.com/a/1096938/7355697) to that second question you posted works great, but only for the element that receives focus _last_. I've tried experimenting with multiple `setTimeout` calls with different timeouts and have had no luck. – alexleen Feb 26 '19 at 21:18

0 Answers0