[英]How to fetch variables.env variables in Angular and assign it to environment.ts or environment.prod.ts
I have build a docker which contains angular 4 application ,other services like superlogn,feedparser and database couchdb. 我已经构建了一个包含angular 4应用程序的docker,其他服务如superlogn,feedparser和数据库couchdb。
Presently in my root folder i have a varibales.env file where all the variables are declared and can be accessed in superlogin and feedparser services 目前在我的根文件夹中,我有一个varibales.env文件,该文件中声明了所有变量,并且可以在superlogin和feedparser服务中对其进行访问
But if we access the varaiables in angular application liks 但是如果我们在角度应用程序中访问变量
dbusername=process.env.username dbusername = process.env。用户名
then the error we getting in angular production is process is undefined? 那么我们在角度生产中得到的错误是过程是不确定的?
unable to access process.env in angular 4 application? 无法在angular 4应用程序中访问process.env?
the Github link for the project is 该项目的Github链接是
https://github.com/janastu/iihs_couch_services/ https://github.com/janastu/iihs_couch_services/
Because Angular don't have access (and should not) to environment variables. 因为Angular不能(也不应该)访问环境变量。 This is very dangerous for your system.
这对您的系统非常危险。
If you want to expose your environments variables, which I don't recommend, you should create a Node application and make endpoints that return your environment variables. 如果您不想公开环境变量(我不建议这样做),则应创建一个Node应用程序,并使端点返回您的环境变量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.