Friday, February 8, 2019

Use environment.ts for the Web.config/appsettings.json settings stuff in an Angular 7 app.

In contrast to this, there is now a default way to keep settings as explained here. There will be an "environments" folder in the "app" folder of any Angular application made with the Angular-CLI and it will have environment.ts inside holding, for starters:

export const environment = {
   production: false
};

 
 

environment.prod.ts will sit beside environment.ts and it holds, for starters:

export const environment = {
   production: true
};

 
 

Loop in the environment at a service like so:

import { environment } from '../../environments/environment';

 
 

Get stuff from the environment like this:

let isProduction = environment.production;

 
 

environment.ts versus environment.prod.ts probably has to do with production mode, huh?

No comments:

Post a Comment