Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

290
Vistas
Accessing Electron API from Angular Component

I'm looking to load a locally saved video file via electron and play it in my angular component. For this, I have the loadLocalFile function that I expose in order to avoid setting nodeIntegration to true. I still get this Security Warning :

This renderer process has either no Content Security Policy set or a policy with "unsafe-eval" enabled. This exposes users of this app to unnecessary security risks.

I do not have a renderer.js file as I'm using Angular. How am I meant to access my electronAPI in my Angular?

My Preload.js contains the following, which I want to call from my Angular component:

contextBridge.exposeInMainWorld("electronAPI", {
  loadLocalFile: (event, filePath) => {
    if (filePath === undefined) {
      console.log("No file selected");
      return;
    }

    dialog.showOpenDialog((filePath) => {
      // fileNames is an array that contains all the selected
      if (filePath === undefined) {
        console.log("No file selected");
        return;
      }

      fs.readFile(filePath, "utf-8", (err, data) => {
        if (err) {
          alert("An error ocurred reading the file :" + err.message);
          return;
        }

        // Change how to handle the file content
        console.log("The file content is : " + data);
      });
    });
  },
});

My app.module.ts conains the following:

export interface IElectronAPI {
  loadLocalFile: (event: Event | null, path: string) => Promise<void>;
}

declare global {
  interface Window {
    electronAPI: IElectronAPI;
  }
}

in my Angular Component I access the Api with:

window.electronAPI.loadLocalFile(null, "/path/to/my/video");

How are you meant to implement the electron API access from your Angular component? A service would probably work well, but I couldn't find or come up with a working example that isn't broken by the removal of certain imports

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

you can use ngx-electron. which helps to you calling Electron APIs from the Renderer Process easier.you can easily able to use into Angular project. but I am not sure able that it will helps to read video file or not.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda