Hi all,
I have a question for you. I should load an external file, a JSON file,
containing environment variables.
For example:
export class ClientService {
...
checkMail(...): any {
return this.http.post(`${this.conf.hostServer}/api/otp`, ...)
}
In this case I have this.conf.hostServer that must be read from another
class.
@Injectable()
export class ConfigService {
env: string
constructor(public http: HttpClient) {
this.setSocketServer();
}
setSocketServer() {
return new Promise<boolean>((resolve: (a: boolean) => void): void => {
this.http.get('./config.json').pipe(map((x: any) => {
this.env = x.env;
resolve(true);
}))
.subscribe();
});
}
}
In this way I have in my ClientService the correct variables but I have to
wait in my components that they are ready.
How can I do this ?
I saw that is present another way using APP_INITIALIZE but I don't like it
for this case.
What do you suggest me ?
Thanks.
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/angular/1c009e07-760b-40de-9ac8-132c62af34c7%40googlegroups.com.