To implement runtime configuration: Add a JSON config file to the /src/assets/ folder (so that is copied on build) Create an AppConfigService to load and distribute the config. Load the configuration using an APP_INITIALIZER.
A file named angular. json at the root level of an Angular workspace provides workspace-wide and project-specific configuration defaults for build and development tools provided by the Angular CLI. Path values given in the configuration are relative to the root workspace folder.
The Angular has the environment variables where you can keep the runtime settings, but it has limitations. The setting of the environment variables are defined at build time and cannot be changed at run time. We can keep the configuration information in a database.
In Angular (Type Script) there are many config files. Which is the right one to save a global setting?
For example, when I am calling API from local then my rootUrl
is localhost:42000
but when I switch on production it should be http:www.someting.com
.
I want to save this rootUrl
in some global place so if I switch on production then I only have to change in this rootUrl
.
Please suggest where should I save these global settings, same as web.config in Asp.Net.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With