Angular2- Environment Specific Configuration
In order to support environment configuration, Angular2 provides environment.ts file in the app folder. Here we can have all the configurations we want.
There are also environment specific configurations in config folder. Here we have two different files environment.dev.ts and environment.prod.ts for dev and prod environments respectively. In these configs, we can do environment specific overrides of our choice.
Of course, we can still build the project using ng’s build command.
Building the project, generates the finalized environment.js file for a particular environment. By default, it uses dev environment.
In order to use prod’s environment configuration file, we can just use –environment=prod. Running the build with just [ng build –prod] should also have the same effect.
We can verify that correct config values are generated. The difference is that they get generated in main.js file instead of environment.js file.
Using Environment Configs
And we can definitely use it in our template file.
Just make sure that you run it again with ng serve -prod.