Where to save global settings in Angular 4

后端 未结 4 2254
被撕碎了的回忆
被撕碎了的回忆 2021-02-19 05:45

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 rootUr

4条回答
  •  天命终不由人
    2021-02-19 06:10

    When I first started using Angular 2, I used a global.ts file where I'd put all my variables, so that I could change it easily.

    I've then discovered the environments provided by angular CLI. All you have to do is name a file environment.prod.ts (for prod), and use ng build --prod when you build it. when you develop, use the environment.ts file and both files have to have the same variables.

    I hope this answers your question.

提交回复
热议问题