Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

291
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!