Angular 2: define static variable based on environment -


is possible define static variable based on environment?

something (this code silly example holds idea):

if (environment.production) {    public static my_var: string = 'a'; } else {    public static my_var: string = 'b'; } 

thanks advice!

what read url window.location.host when application bootstrapped first time , according dev,qa , uat url set api endpoint in application. how achieve this?

in main.ts file

 platformbrowserdynamic([{provide:'endpoint',usevalue:config.getendpoint()}])  export class config{ public static getendpoint(){ const host = window.location.host if(host) // logic goes here{  } } } 

in service inject like

constructor(@inject('endpoint') private endpoint:string) 

Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -