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
This answer is similar to @trichetriche, with few more details on the code.
For development/testing
purpose
environment.ts
export const environment = {
production: false,
appUrl: 'localhost:4200'
};
For production
environment.prod.ts
export const environment = {
production: true,
appUrl: 'mywebsite.com'
};
Usage
service.ts
import { environment } from '../../environments/environment';
this._http.get(environment.appUrl, requestHeaders(options));
Make a note of production
parameter in all the environment
files.
I believe you could also create more environments like environment.unittesting.ts
.