I'm using ipcRenderer to retrieve the folder path from a browser dialog in my main.js.
But for some reason it does not update my the text string on my view.
I know in order for this to work I need to do a setTimeout for it to update (thanks google!). But for some reason this does not work.
Code I use is the following.
import { Component, OnInit } from '@angular/core';
declare var electron: any;
@Component({
selector: 'my-app',
template:
//added (click)="debug()" in order to update the {{path}} manually
`<h1 (click)="debug()">My First Angular 2 App with Electron</h1>
<br />Project Path: {{[(path)]}}
<button (click)="btnClick()">Select project path</button>
<br /> <br />`
})
export class AppComponent implements OnInit {
ipc:any;
path:string;
constructor(){
this.path = __dirname;
}
ngOnInit(){
electron.ipcRenderer.on('project-path-reply', (event, arg) => {
setTimeout(() => {
this.path = arg.return[0];
console.log('updated')
})
})
}
btnClick(){
electron.ipcRenderer.send('project-path',1);
}
debug(){
console.log(this.path);
}
}
Can someone point me in the right direction this is my first app using electron.
Kind Regards,
Thyvo
contructor(private ref ChangeDetectorRef){}
then in callbackref.detectChanges()
? – Gond