I\'m using angular 5 and httpclient. I\'m not a big fan of the built in environments to set up my environment api url\'s that I need to consume. I have switched to using an ngin
A simple way to do it is like this:
class Constants {
public api1: string;
public api2: string;
public setApi1(api: string) {}
public setApi2(api: string) {}
}
export const CONSTANTS: Constants = {
api1: "DEFAULT API 1",
api2: "DEFAULT API 2",
setApi1(api: string) : void {
this.api1 = api;
},
setApi2(api: string) : void {
this.api2 = api;
}
}
Then just import your const
wherever you need the persistence:
import {CONSTANTS} from "../path/to/constant.ts";