Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to save global settings in Angular 4

Tags:

People also ask

How to add config file in Angular?

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.

What is Angular JSON file for?

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.

What is runtime in Angular?

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.