As a newcomer to Angular, I am currently working on building an electron app with Angular 6.
My objective is: 1. Implementing SupportInformationClass with specific definitions 2. Initializing the component to populate the definitions from electron-settings
supportInformation.ts:
export class SupportInformation {
appsSet1: string[];
//appsSet2: string[];
//appsSet3: string[];
//appsSet4: string[];
}
configuration.componenet.ts:
import { SupportInformation } from './supportInformation';
...
...
export class ConfigurationComponent implements OnInit {
supportInformation: SupportInformation;
constructor(private childProcessService: ChildProcessService, private electronService: ElectronService) {
console.log("inside constructor...")
}
ngOnInit() {
console.log("on ngInit...");
this.getSupportedApps();
}
getSupportedApps() {
if(this.childProcessService.isElectronApp){
// this.supportInformation.appsSet1 = ["wow"] // this works
console.log(this.electronService.settings.get('APPS_1')) // this also works
this.supportInformation.appsSet1 = this.electronService.settings.get('APPS_1'); // this gives an error
}
}
}
Despite 'this.electronService.settings.get('APPS_1')' returning an array of string elements, I encounter an error on the specified line.
this.supportInformation.appsSet1 = this.electronService.settings.get('APPS_1');
Error:
Type 'JsonValue' is not assignable to type 'string[]'.
Type 'string' is not assignable to type 'string[]'.
This is how my settings file looks like:
{
...
"APPS_1": ["abc", "def", "ghi", "jkl"],
"APPS_2": ["mno", "pqr"],
...
}
Upon using 'console.log(this.electronService.settings.get('APPS_1'))', this is what it returns:
https://i.sstatic.net/Dsc34.png
I'm puzzled by this issue. Any guidance or suggestions would be much appreciated.
Thank you.