1

I am using docker so, in production mode I am using linked containers with URLs like "http://api:3000/" instead of "http://localhost:3000/" while in dev mode.

I would like to be able to use "http://api:3000/" if "ng build -prod" and stay with "localhost" while developing.

How can I do my if( "-prod" ) ?

Thanks for reading me, I hope my question is clear.

EDIT: Everything was explain in a commentary in environment.ts enter image description here

The Segfault
  • 939
  • 1
  • 10
  • 23
  • 1
    If you just want to change variables between development mode and production mode, take a look at [this](http://stackoverflow.com/questions/43136109/angular2-how-to-switch-baseurl-between-prodmode-and-test-mode/43157274#43157274). – ulubeyn May 03 '17 at 09:25

1 Answers1

1

You have environments/environment.ts, and there is a json

export const environment = {
    production = false
};

And you can access it within your application with importing it and then using it with if(environment.production)

or use the built in angular module like in How to check if Angular 2 app is running in production or dev

daddycool
  • 113
  • 2
  • 6
  • 1
    Thanks, I knew that I had this code in my environment.ts but I didn't know if it is linked or not with "ng build -prod" OK, I just found a nice commentary in environment.ts that explain everything, Thanks ! – The Segfault May 03 '17 at 09:51