I build an angular app and then wrapped it using Electron.
My dir structure looks like this :
Project
|--electron
---|-main.js
-----|-index.html (and other files copied from webapp/dist)
|--webapp (angular app)
---|-src
-----|-app
-------|-service
I tried inter-process communication (ipcMain and ipcRenderer) but it got hanged up!
Then I came to know about webcontent.executeJavascript();
So I made a service in angular which has a various functions like eventFromHost() & sendMessage().
how do I call this function from electron's main.js using webcontent or any other method?
You should use
ipcMainandipcRendererfor that:In Angular:
In electron:
Or same using
ipcRendererto make electron => angular communication (ipcMainbeing to communicate from angular to electron).If you want to see a live example, check this main.js file on github, and the service that communicates with it here in angular.