load it using your basic

const typeDefs = require("./config");

On Monday, August 12, 2019 at 7:32:48 AM UTC-7, marc wrote:
>
> 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/21acc184-c478-470a-b6cb-9c6baf5c8a80%40googlegroups.com.

Reply via email to