Sharing Top Content from the Angular-sphere.

Where To Store Angular Configurations

Where To Store Angular Configurations

  • I know it is tempting, but the environment.ts and environment.prod.ts files were never meant for configuration information other than to tell the run-time you are running a production version of the code instead of developing the code locally.
  • Yes, I know it is possible to create a file for your different environments and you can effectively use the file for your configuration information.
  • The advantage to the database method is that you can have one database that handles the configuration information for all of your applications and even all of your environments.
  • So when you get to the place in your code where you need the configuration information, you can be sure it has been loaded.
  • The promise function loads your configuration information and stores it in your application.

Because this is a frequent problem, because it is so often done incorrectly and because there are some pretty great alternatives, today I want to discuss where to store Angular configurations.  You  know, all that information that changes as you move from your local development environment to the Development, QA and Production servers?  There’s a place for that.

I know it is tempting, but the environment.ts and environment.prod.ts files were never meant for configuration information other than to tell the run-time you are running a production version of the code instead of developing the code locally.  Yes, I know it is possible to create a file for your different environments and you can effectively use the file for your configuration information.  But, just because you can, doesn’t mean you should.

In an ideal world, you would build a release candidate and place it on your Development server and then move it from there to QA and then to Production.  You would never rebuild the application.  You want to be absolutely sure that the code you tested in the Development environment is the code you ran in the QA environment and that the code you ran in the QA environment is the code that is running in the Production environment.  You want to know for sure that the only possible reason why something isn’t working is because the configuration information is incorrect.

If we can’t put our configuration information in our code, where do we…

Where To Store Angular Configurations