I have another way to define global settings. Because, if we defined ts in the file, if we build in production mode, it is not so easy to find constants for changing the value.
export class SettingService {
constructor(private http: HttpClient) {
}
public getJSON(file): Observable<any> {
return this.http.get("./assets/configs/" + file + ".json");
}
public getSetting(){
}
}
In the application folder, I add the configs / setting.json folder
Content in setting.json
{
"baseUrl": "http://localhost:52555"
}
In the application module add APP_INITIALIZER
{
provide: APP_INITIALIZER,
useFactory: (setting: SettingService) => function() {return setting.getSetting()},
deps: [SettingService],
multi: true
}
that way I can change the value in the JSON file easier.
I applied this in a project for baseUrl, dateformat, sessiontimeout ...
source
share