I am working with angular 5 application and deploying to private cloud foundry. In general, while building the application we would provide API endpoint in "environment.{*}.ts" file and run npm run build --prod command.
my requirement is to read user provided environment variables after deployment. I am new to PCF.
Thanks in advance.
One way to accomplish this is to use Angular Universal to do your initial render server-side via Node.
As part of your Angular Universal setup, you'll have a server.ts file, which can read any environment variables you need. I chose Nunjucks for this example to render the index.html from the Angular application (I'm sure you can use EJS or another templating engine).
In your index.html, you can output the server-side variables wherever you need. I chose to assign a value to the
window
here calledenvironment
.Subsequently in Angular components, services, etc, you can access the value via
window['environment'].someValue