Access methods of Ionic App in Electron renderer window

I am porting a web-app written with the ionic/angular framework to a desktop app using Electron. I would like to keep the web-app code unchanged as drop-in code to simplify maintenance. I have it working well, and I am putting in the finishing touches.

The final touch is to save the user’s preferences (such as choice of kg vs lbs) between uses of the desktop app. The web app allows changing the preferences with buttons but does not have persistence.

I have figured how to navigate the DOM during a window closes event to determine what the user has chosen, so that I can read the current state and store it.

What I have not been able to do is set the preferences when the page loads at app start. My plan is to add code in the window.eventEventListener DOMContentLoaded event handler. I have tried the following, each of which works on a modified version of the example code for electron, which does not use ionic or angular, but not on the target code itself.

Calling the instance method HomePage.toggleKG() , or toggleKG() . Both get a not defined error. Finding the user button in the DOM and then using its . click() event. I can find the button, but calling the click event does not throw an error, but nothing changes.

It seems that either angular or ionic is creating a context or closure which prevents me from accessing the methods or even the button.

How can I access one or the other?