I have a service that provides config
data.
@Injectable()
export class ConfigData {
someObj: any;
constructor(private http: HttpClient) {
this.http.get('/config-data').subscribe((data) => {this.someObj = data})
}
}
And now I want to use the object to set a static variable in another service.
@Injectable()
export class AnotherService {
public static A_STATIC_VAR = ConfigData.someObj.specific_value
constructor(){}
}
If I add ConfigData
to the constructor in AnotherService
it's useless because it doesn't assign the value to the static variables in time. They are already "undefined" by the time they are used elsewhere.
Is there any way to accomplish this?