In the code snippet below, you will find my class that includes a static member called config.
import {Injectable} from '@angular/core';
import {Config} from '../shared/interfaces'
export class GlobalData {
static config: Config = {
appName: "",
line: "",
}
constructor(private app: PApplication){
GlobalData.config.appName = app.getData().Style ? 'P_APP' : 'P_WEB'
GlobalData.config.line = 'PApp'
}
}
Here is the interface Config that's utilized in the above code:
export interface Config {
appName: string
line: string
}
The goal is to pass the static config object to the following function:
var appConfig = this.appConfig(GlobalData.config);
appConfig = (configVariable: Config) => {
return _.map(configVariable, function(val, key) {
return key + "=" + val;
}).join("&");
}
An error has been encountered during this process:
[ts] Argument of type 'Config' is not assignable to parameter of type 'List<{}> | Dictionary<{}> | NumericDictionary<{}>'. Type 'Config' is not assignable to type 'NumericDictionary<{}>'. Index signature is missing in type 'Config'.
Previously, in Javascript, the config was defined as a global object accessible across different controllers and services.
var config = {appName: "", line: "" }