通过ipcRenderer将电子数据发送到Angular服务

时间:2019-05-06 14:51:11

标签: angular electron communication

目前,我正在尝试创建具有角度的电子应用。我找到了一个Github项目来运行一个基本项目,但我的目标是在电子main.js和Angular服务之间建立通信。
通常,在没有角度的情况下,main.js和index.html之间的通信非常容易:

基本上是这样的交流

//main.js :

mainWindow.webContents.send("getOutput","hello html"); // calls ipcRenderer methode with specific string in index.html


//index.html : 

ipcRenderer.on("getOutput",data,function () {
// gets called
console.log(data); // prints "hello html"
var testAnswer = "Hello from HTML"
ipcRenderer.send("outputAnswer", test answer); // calls ipcMain.once with the matching string as parameter 
 });


//main.js

ipcMain.once("outputAnswer", function (event, answer) {
 console.log(answer); //prints Hello from HTML
}

是否有可能实现电子main.js与角度服务之间的通信?我找到了一个名为“ ngx-electron”的npm软件包,该软件包可以解决问题,但遗憾的是,由于限制,我无法使用该软件包

0 个答案:

没有答案