• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

338
Views
Electron/Angular : How to use typescript component functions/variables in main.js

I am new to angular , electron.

I am trying to use type script component functions/variables in main.js.

I have LicesneController component which holds emailId, I want to call some methods at the time of tool closure which required emailId(stored in loginCompoenent).

I tried several ways to achieve this :

  1. Local and session storage: Not worked as they cannot be used at client side. : giving error as localStorage is not defined
  2. Include LicesneController module in main.js const { LicenseController } = require('./src/lib/LicenseController'); : giving Exception as Cann't find module

Question is :

  • why #2 is not working any reason (all the paths are correct) ?
  • Is there any other way to achieve this scenario ?
  • If we are using node local storage , how we can hold values set in ts file and use in js file for node local storage.
about 3 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I have resolved this scenario by using win.webContents.send and ipc renderer.

I was trying to call typescript methods from main.js

in main.js:

    win.webContents.send('On Close');

in typeScript : app.component.ts :

ipcr: IpcRenderer;


  ngOnInit() {
    this.ipcr = window.ipcRenderer;
    this.ipcr.on('On Close', (event, arg) => {
      // Do Some stuff here
    });
  }
about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error