-1

I'm trying to add a feature to an existing electron app that uses Angular -- basically I just inject my script once the app is loaded. I want to adding a hotkey to speed up my workflow, the hotkey would virtually click an edit button, append some text to a textarea, and click a save button. The clicks work fine, but the change I make to the text field vanishes when it clicks save, and I gather this is because it's an Angular app and it's not detecting the change to the textarea. I don't speak Angular and I'm a bit baffled trying to understand enough.

I see methods like ChangeDetectorRef.detectChanges which seems relevant but as I'm outside the Angular code I've got no idea how to get a handle to the relevant ChangeDetectorRef to make that call.

Quinxy von Besiex
  • 976
  • 11
  • 21
  • If the way you append text to the textarea trigger a change event, Angular change detection will run automatically. You can try to dispatching an event manually: https://stackoverflow.com/questions/2856513/how-can-i-trigger-an-onchange-event-manually – Yannick Beauchamp-H Feb 14 '21 at 07:43

1 Answers1

0

I found my own answer...

let el = document.getElementById('foo');

let comp = ng.getContext(el);

comp.$implicit.foo += "\n" + "bar";

When I access the form content that way changes are detected and saved.

Quinxy von Besiex
  • 976
  • 11
  • 21