I am now reading the angular4 doc, and noticed, there is one folder, environments, and under which, there are multiple environment files, such as environment.ts, environment.prod.ts, if we build using env=prod, then prod environments variable will be used.
Now I have one question, how can I get environment variable from the code? I googled the doc quite a lot and there is no mention about this.
Can anyone help to tell me how to obtain environment variable values?
Thanks
Angular – how can we use environment variable in angular version >=2
angular
Best Answer
In dev environment file, you can write
And in prod environment file, you can write
In components or services, you can use like
You can command: