angular-electron icon indicating copy to clipboard operation
angular-electron copied to clipboard

ipRenderer.on doesnt see component variables

Open aleksey-hariton opened this issue 2 years ago • 1 comments

Sending event from main.js, Angular receiving event, but can see any component variables. Looks like ipcRenderer.on dont see component variables, this example giving me undefined in console (using latest master from GitHub).

  public showProgress: boolean = false

  constructor(
    private es: ElectronService,
    ) { 
    }

  ngOnInit(): void {
    this.es.ipcRenderer.on("triedLogin", function (evt, success: boolean) {
      console.log(this.showProgress)
    })
  }

aleksey-hariton avatar Aug 03 '22 14:08 aleksey-hariton

I may be wrong, but doesn't "function" have it's own "this" scope? It should work if you use arrow syntax

ac566 avatar Aug 09 '22 01:08 ac566

Thanks @ac566, you're right :) I close the issue.

maximegris avatar Aug 12 '22 09:08 maximegris