简体   繁体   中英

How to access environment variables from assets folder instead of environment.ts file in angular application

I have to externalize environment variables in my angular 6 application. I want to place these properties in assets folder and then access them in my application so that these environment variables can be changed without build.

How I can make sure that these environment properties are loaded before loading the app because my application is hitting some rest api on startup and it would require those variables on startup.

Regularly all files from the assets folder will be copied into your output (/dist) folder when you are building your app. So therefore you can load every file over the http API from angular.

The complete example is in the angular docs:
https://angular.io/guide/http

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM